ios中常用小技巧注意点

1.设置图片原图显示

 UIImage*image=[UIImage imageNamed:@"place_map.png"];
UIImage*original=[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithImage:original style:UIBarButtonItemStylePlain target:self action:@selector(locationPress)];

2.修改全局barButton渲染颜色 和字体样式

 UINavigationBar *navgationBar = [UINavigationBar appearance];
navgationBar.tintColor = [UIColor colorWithRed:0.61f green:0.61f blue:0.61f alpha:1.00f];
  [[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:15],NSForegroundColorAttributeName:UIColorWithHexRGB(0xfe6d27)}];

 [[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:10],NSForegroundColorAttributeName : kRGBCOLOR(170,170,170)} forState:UIControlStateNormal]

3.隐藏tabbar

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
viewController.hidesBottomBarWhenPushed = YES;
[super pushViewController:viewController animated:animated];

if (self.childViewControllers.count==1) {

    viewController.hidesBottomBarWhenPushed = NO;

}
}

4、TableView的Group样式中,默认的每个section都有sectionHeader和sectionFooter,只要调整这两个的大小就可以实现section之前的间距扩大或缩小

//tableview自带35距离
self.tableView.contentInset = UIEdgeInsetsMake(-35,0,0,0);

5.获取label大小

textLabel.size = [textLabel.text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, textLabel.font.lineHeight)
                                              options:NSStringDrawingUsesLineFragmentOrigin
                                           attributes:@{NSFontAttributeName : textLabel.font}
                                              context:nil].size;

6、tableviewcell让分割线从头开始

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath  
{  
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {  
    [cell setSeparatorInset:UIEdgeInsetsZero];  
}  

if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {  
    [cell setLayoutMargins:UIEdgeInsetsZero];  
}  
}  
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一个男孩杀了人 藏到了一个村庄 看到一个橘子摊却迟迟不走 这时一直细长的手伸了过来 女孩:吃吧男孩看了眼橘子摊的老...
    AlikeBoo阿峰阅读 213评论 1 0
  • 第一次在简书上写文章,从高中时代起,一直在百度空间上写随笔,久而久之成了习惯。然而最近两年来美国后,写的东西开始越...
    不要海鲜的薄礼阅读 506评论 0 2
  • 有句俗语叫“一方水土养育一方人”,家乡富水河流淌过的村庄、集镇和县城,自然而然地享受着它的滋润与馈赠。 明清时代,...
    陈三白阅读 2,075评论 2 2