iOS你不知道的事①
2014-11-04 19:44
155 查看
一下内容 全是本人的心血总结 不喜勿喷
1.改变系统tabbar字体颜色
iOS5 [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"AmericanTypewriter" size:20.0f],UITextAttributeFont,[UIColor yellowColor],UITextAttributeTextColor,[UIColor redColor],UITextAttributeTextShadowColor,[NSValue
valueWithUIOffset:UIOffsetMake(0.0f,1.0f)],UITextAttributeTextShadowOffset,nil] forState:UIControlStateNormal];
iOS7 [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor orangeColor] } forState:UIControlStateSelected];
2.自定义导航栏左右两边的按钮图片
UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[leftBtn setBackgroundImage:[UIImage imageWithNamed:@"navigationbar_friendsearch"] forState:UIControlStateNormal];
[leftBtn setBackgroundImage:[UIImage imageWithNamed:@"navigationbar_friendsearch_highlighted"] forState:UIControlStateHighlighted];
leftBtn.frame = (CGRect){CGPointZero,leftBtn.currentBackgroundImage.size};
//或者
// leftBtn.frame = CGRectMake(0, 0, leftBtn.currentBackgroundImage.size.width, leftBtn.currentBackgroundImage.size.height);
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:leftBtn];
导航栏文字颜色设置
self.navigationItem.rightBarButtonItem.tintColor=[UIColor orangeColor];
3.1设置颜色 为指定的图片
……. = [UIColor colorWithPatternImage:[UIImage imageNamed:@"1.png"]];
3.2 禁止pageControl 点击旁边是 会进行翻页的鲜果
_pageControl.userInteractionEnabled = NO;
3.3 按钮Button内部结构
按钮的左边是一个Image 右边是一个label
例如:
btn.selected = YES;//本身就有一个选中的属性 当选中时可以换一个image 等等
[btn setTitle:@"分享给大家" forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamed:@"new_feature_share_false"] forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamed:@"new_feature_share_true"] forState:UIControlStateSelected];
[btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
btn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);//设置title 上左下右的间距
checkbox.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 10);//设置图片 上左下右的间距
4.//去掉cell之间的线条
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
字符串替换
NSString *count = @"4.0万";
[count stringByReplacingOccurrencesOfString:@".0" withString:@""];
5.时间格式转换(此法仅适用于mark系统 不适于UI界面)
Fri Oct 10 17:19:06 +0800 2014
转成 2014-10-10 17:19:06 +0800
方法
NSDate *time = [NSDate dateWithNaturalLanguageString:@"Fri Oct 10 17:19:06 +0800 2014"];
NSLog(@"time is %@",time);
打印结果: time is 2014-10-10 17:19:06 +0800
6.//scrollView使用 使上面的UI控件从 y->0 开始;
self.automaticallyAdjustsScrollViewInsets = NO;
1.改变系统tabbar字体颜色
iOS5 [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"AmericanTypewriter" size:20.0f],UITextAttributeFont,[UIColor yellowColor],UITextAttributeTextColor,[UIColor redColor],UITextAttributeTextShadowColor,[NSValue
valueWithUIOffset:UIOffsetMake(0.0f,1.0f)],UITextAttributeTextShadowOffset,nil] forState:UIControlStateNormal];
iOS7 [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor orangeColor] } forState:UIControlStateSelected];
2.自定义导航栏左右两边的按钮图片
UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[leftBtn setBackgroundImage:[UIImage imageWithNamed:@"navigationbar_friendsearch"] forState:UIControlStateNormal];
[leftBtn setBackgroundImage:[UIImage imageWithNamed:@"navigationbar_friendsearch_highlighted"] forState:UIControlStateHighlighted];
leftBtn.frame = (CGRect){CGPointZero,leftBtn.currentBackgroundImage.size};
//或者
// leftBtn.frame = CGRectMake(0, 0, leftBtn.currentBackgroundImage.size.width, leftBtn.currentBackgroundImage.size.height);
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:leftBtn];
导航栏文字颜色设置
self.navigationItem.rightBarButtonItem.tintColor=[UIColor orangeColor];
3.1设置颜色 为指定的图片
……. = [UIColor colorWithPatternImage:[UIImage imageNamed:@"1.png"]];
3.2 禁止pageControl 点击旁边是 会进行翻页的鲜果
_pageControl.userInteractionEnabled = NO;
3.3 按钮Button内部结构
按钮的左边是一个Image 右边是一个label
例如:
btn.selected = YES;//本身就有一个选中的属性 当选中时可以换一个image 等等
[btn setTitle:@"分享给大家" forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamed:@"new_feature_share_false"] forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamed:@"new_feature_share_true"] forState:UIControlStateSelected];
[btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
btn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);//设置title 上左下右的间距
checkbox.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 10);//设置图片 上左下右的间距
4.//去掉cell之间的线条
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
字符串替换
NSString *count = @"4.0万";
[count stringByReplacingOccurrencesOfString:@".0" withString:@""];
5.时间格式转换(此法仅适用于mark系统 不适于UI界面)
Fri Oct 10 17:19:06 +0800 2014
转成 2014-10-10 17:19:06 +0800
方法
NSDate *time = [NSDate dateWithNaturalLanguageString:@"Fri Oct 10 17:19:06 +0800 2014"];
NSLog(@"time is %@",time);
打印结果: time is 2014-10-10 17:19:06 +0800
6.//scrollView使用 使上面的UI控件从 y->0 开始;
self.automaticallyAdjustsScrollViewInsets = NO;
相关文章推荐
- 《iOS 7 Programming Pushing the Limits》系列:你可能不知道的ObjC技巧
- 不知道大家知道不知道,iOS开发,web页面的链接的active属性无效,但是今天发现一个hack办法可以让Css的active有效
- iOS开发-文件管理之多的是你不知道的事(二)
- iOS UIScrollView 你可能不知道的奇技淫巧
- iOS 10 个实用小技巧(总有你不知道的和你会用到的)
- iOS10个实用小技巧(总有你不知道的和你会用到的)
- iOS应用安全开发,你不知道的那些事
- iOS“断点”(Break Point)你不知道多强大
- Android IOS WebRTC 音视频开发总结(六四)-- webrtc能走多远我不知道,但这个市场真实存在
- 【ios 汇总 你可能不知道的调试技巧】
- iOS开发(你不知道的小细节)之---导航栏
- 关于UITabbarItem在iOS 8 上显示不知道哪里来的蓝色并且模糊的问题解决办法
- iOS开发-文件管理之多的是你不知道的事(一)
- 关于UITabbarItem在iOS 8 上显示不知道哪里来的蓝色并且模糊的问题解决办法
- iOS Timer--你不知道的那些事儿
- iOS应用安全开发,你不知道的那些事
- iOS开发(你不知道的小细节)之---状态栏
- 土木工程转行IOS的点点滴滴,没受伤是不知道回头滴
- iOS 10 个实用小技巧(总有你不知道的和你会用到的)
- ios中常用的小技巧(总有你不知道的和你会用到的)