IOS开发常用代码汇总4

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];

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值