1,直接退出应用
- (void)exitApplication { AppDelegate *app = [UIApplication sharedApplication].delegate; UIWindow *window = app.window; [UIView animateWithDuration:1.0f animations:^{ window.alpha =0; } completion:^(BOOL finished) { exit(0); }];}
2,改变cell 默认右视图颜色
tableView.tintColor = [UIColor redColor];
3,调整默认分割线位置调整
tableView.separatorInset = UIEdgeInsetsMake(0,100,0,0);
cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, 10);
4,滑动隐藏navigationbar
navigationController.hidesBarsOnSwipe = Yes
5,设置button不被同时点击 button全局
[[UIButton appearance] setExclusiveTouch:YES];
6,修改textFieldplaceholder字体颜色和大小
textField.placeholder =@"username is in here!";
[textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
[textField setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"];
7,有时候使用UITableView所实现的列表,会使用到section,但是又不希望它粘在最顶上而是跟随滚动而消失或者出现
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {if(scrollView == _tableView) {
CGFloat sectionHeaderHeight =36;
if(scrollView.contentOffset.y <= sectionHeaderHeight && scrollView.contentOffset.y >=0) {
scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y,0,0,0); }
elseif(
scrollView.contentOffset.y >= sectionHeaderHeight) {
scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight,0,0,0);
} } }
8.改变uitextfield placeholder的颜色和位置
继承uitextfield,重写
- (void) drawPlaceholderInRect:(CGRect)rect {
[[UIColor blueColor] setFill];
[self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment];
}
9.把我的navigationbar弄成透明的而不是带模糊的效果
[self.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage new];
self.navigationBar.translucent = YES;
10.拉伸图片的时候让图片部分不变形
UIImage *image = [[UIImage imageNamed:@"xxx"] stretchableImageWithLeftCapWidth:10 topCapHeight:10];
11.捕捉iphone 通话事件
CTCallCenter *center = [[CTCallCenter alloc] init];
center.callEventHandler = ^(CTCall *call)
{
NSLog(@"call:%@", call.callState);
}