IOS开发常用代码汇总4
2013-01-24 10:01
295 查看
31.状态栏的网络活动风火轮是否旋转
[UIApplication sharedApplication].networkActivityIndicatorVisible,默认值是NO。
32.线程使用
//创建线程
[NSThread detachNewThreadSelector:@selector(myMethod) toTarget:selfwithObject:nil];
//线程方法
- (void)myMethod
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
*** code that should be run in the new thread goes here ***
[pool release];
}
//在主线程中调用
[self performSelectorOnMainThread:@selector(myMethod) withObject:nilwaitUntilDone:false];
33 app Icon显示数字:
-(void)applicationDidEnterBackground:(UIApplication *)application{
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:5];
}
34.UIScrollView 设置滑动不超出本身范围:
[fcScrollView setBounces:NO];
35. NSArray查找是否存在对象时用indexOfObject,如果不存在则返回为NSNotFound.
36. 在使用UISearchBar时,将背景色设定为clearColor,或者将translucent设为YES,都不能使背景透明,经过一番研究,发现了一种超级简单和实用的方法:
[[searchbar.subviewsobjectAtIndex:0]removeFromSuperview];
背景完全消除了,只剩下搜索框本身了。
37. 对图层的操作:
(1.给图层添加背景图片:
myView.layer.contents = (id)[UIImageimageNamed:@"view_BG.png"].CGImage;
(2.将图层的边框设置为圆脚
myWebView.layer.cornerRadius = 8;
myWebView.layer.masksToBounds = YES;
(3.给图层添加一个有色边框
myWebView.layer.borderWidth = 5;
myWebView.layer.borderColor = [[UIColorcolorWithRed:0.52 green:0.09 blue:0.07 alpha:1] CGColor];
[UIApplication sharedApplication].networkActivityIndicatorVisible,默认值是NO。
32.线程使用
//创建线程
[NSThread detachNewThreadSelector:@selector(myMethod) toTarget:selfwithObject:nil];
//线程方法
- (void)myMethod
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
*** code that should be run in the new thread goes here ***
[pool release];
}
//在主线程中调用
[self performSelectorOnMainThread:@selector(myMethod) withObject:nilwaitUntilDone:false];
33 app Icon显示数字:
-(void)applicationDidEnterBackground:(UIApplication *)application{
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:5];
}
34.UIScrollView 设置滑动不超出本身范围:
[fcScrollView setBounces:NO];
35. NSArray查找是否存在对象时用indexOfObject,如果不存在则返回为NSNotFound.
36. 在使用UISearchBar时,将背景色设定为clearColor,或者将translucent设为YES,都不能使背景透明,经过一番研究,发现了一种超级简单和实用的方法:
[[searchbar.subviewsobjectAtIndex:0]removeFromSuperview];
背景完全消除了,只剩下搜索框本身了。
37. 对图层的操作:
(1.给图层添加背景图片:
myView.layer.contents = (id)[UIImageimageNamed:@"view_BG.png"].CGImage;
(2.将图层的边框设置为圆脚
myWebView.layer.cornerRadius = 8;
myWebView.layer.masksToBounds = YES;
(3.给图层添加一个有色边框
myWebView.layer.borderWidth = 5;
myWebView.layer.borderColor = [[UIColorcolorWithRed:0.52 green:0.09 blue:0.07 alpha:1] CGColor];
相关文章推荐
- [置顶] ios开发常用技巧汇总 + 小功能代码
- IOS开发常用代码汇总1
- IOS开发常用代码汇总2
- IOS开发常用代码汇总3
- IOS开发常用代码汇总5
- Android 开发常用代码汇总
- iOS 快速创建常用UI,使代码更加整洁并且提高开发效率<1>
- iOS开发常用代码【持续更新中】
- 开发中常用代码片段汇总(持续更新)
- IOS/iphone开发之常用代码
- 关于iOS开发常用代码整理
- iOS项目开发经验:【常用代码2】
- iOS项目开发经验:【常用代码3】
- iOS开发常用代码
- iOS开发小技巧:私有API及不常用的API汇总
- IOS开发效率之为Xcode添加常用的代码片段
- ios开发视频播放常用的代码
- iOS开发之17个常用代码整理
- iOS开发之MAC常用快捷键汇总
- ios 开发常用代码