1.調(diào)用代碼使APP進(jìn)入后臺,達(dá)到點(diǎn)擊home鍵的效果
[[UIApplication sharedApplication] performSelector:@selector(suspend)];
2.帶有中文URL處理
http://static.tripbe.com/videofiles/視頻/我的文檔.mp4
NSString *path? = (__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL,? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (__bridge CFStringRef)model.mp4_url,? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CFSTR(""),? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding));
3.獲取WebView的高度
- (void)webViewDidFinishLoad:(UIWebView *)webView? {
CGFloat height = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"] floatValue];
CGRect frame = webView.frame;
webView.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, height);
}
4.給UIView設(shè)置圖片(UILable也可以)
給UIView設(shè)置圖片(UILabel一樣適用)
第一種方法:
利用的UIView的設(shè)置背景顏色方法饮醇,用圖片做圖案顏色昧廷,然后傳給背景顏色。
UIColor *bgColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"bgImg.png"];
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,480)];
[myView setBackGroundColor:bgColor];
第二種方法:
UIImage *image = [UIImage imageNamed:@"yourPicName@2x.png"];
yourView.layer.contents = (__bridge id)image.CGImage;
//設(shè)置顯示的圖片范圍
yourView.layer.contentsCenter = CGRectMake(0.25,0.25,0.5,0.5);//四個值在0-1之間福压,對應(yīng)的為x仿村,y锐朴,width,height
5.去掉UITableView多余的分割線
MyTableView.tableFooterView = [UIView new];
6.收起鍵盤UITableView蔼囊、ScrollView
yourTableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag
UIScrollViewKeyboardDismissModeInteractive焚志,表示在鍵盤內(nèi)部滑動衣迷,鍵盤逐漸下去
7.bringSubviewToFront 將指定視圖推到前面 sendSubviewToBack將指定視圖推到背面
[self.view.window sendSubviewToBack:self.view];