开发随笔 - 常用属性、方法
2015-11-16 11:36
323 查看
导航栏透明:
隐藏无内容cell
去掉cell的点击状态
cell的分割线
cell右侧小箭头
点击self.view收键盘
给button的title加下滑线
label不同颜色
push到下一个界面是,有个过渡的阴影,怎么解决?跳转之前设一下下个页面的背景颜色
去掉返回箭头的title
ScrollView 的contentsize.height=0即可禁止上下滚动
同理contentsize.width =0即可禁止左右滚动。但是7.0系统之后为什么有时候不起效果呢?
因为 如果一个控制器中出现两个以上的UIScrollView(包括其子类),automaticallyAdjustsScrollViewInsets这个属性需要设置为NO.即不会预留空白。(7.0之后默认是YES)
在不缩放图片,不去掉title的前提下,替换backBarButton图片的方法:(原理很简单,第一行加载图片,第二行以加载图片的宽度结合resizableImageWithCapInsets生成一个缩放时不会拉伸的新图片作为BackButtonBackgroundImage,再在第三行设置title的位置偏移到一个不可见的位置,达到隐藏的目的。另外,如果需要全部统一替换,也可以在app的didFinishLaunching里通[UIBarButtonItem appearance]全部统一替换!)
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; [self.navigationController.navigationBar setShadowImage:[UIImage new]];
隐藏无内容cell
myTableView.tableFooterView = [[UIView alloc] init];
去掉cell的点击状态
[myCell setSelectionStyle:UITableViewCellSelectionStyleNone];
cell的分割线
myTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;(样式) myTableView.separatorColor = [UIColor grayColor];(颜色) myTableView.separatorInset = UIEdgeInsetsMake(0,5, 0, 0);(距离上下左右)
cell右侧小箭头
myCell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
点击self.view收键盘
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.view endEditing:YES]; }
给button的title加下滑线
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"查看所有中奖记录"]; NSRange strRange = {0,[str length]}; [str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange]; [_awardDisplayBtn setAttributedTitle:str forState:UIControlStateNormal];
label不同颜色
NSMutableAttributedString *attributeMyPriceStr = [[NSMutableAttributedStringalloc] initWithString:[NSStringstringWithFormat:@"价格:%@元/小时",[dictonary objectForKey:@"myPrice"]]]; NSUInteger myPriceLength = [NSStringstringWithFormat:@"%@",[dictonary objectForKey:@"myPrice"]].length; [attributeMyPriceStr addAttribute:NSForegroundColorAttributeNamevalue:[UIColorredColor] range:NSMakeRange(3, myPriceLength+4)]; _parkPriceLabel.attributedText = attributeMyPriceStr;
push到下一个界面是,有个过渡的阴影,怎么解决?跳转之前设一下下个页面的背景颜色
去掉返回箭头的title
UIBarButtonItem *backItem=[[UIBarButtonItem alloc]init]; backItem.title=@""; self.navigationItem.backBarButtonItem = backItem; 或者: [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];
ScrollView 的contentsize.height=0即可禁止上下滚动
同理contentsize.width =0即可禁止左右滚动。但是7.0系统之后为什么有时候不起效果呢?
因为 如果一个控制器中出现两个以上的UIScrollView(包括其子类),automaticallyAdjustsScrollViewInsets这个属性需要设置为NO.即不会预留空白。(7.0之后默认是YES)
在不缩放图片,不去掉title的前提下,替换backBarButton图片的方法:(原理很简单,第一行加载图片,第二行以加载图片的宽度结合resizableImageWithCapInsets生成一个缩放时不会拉伸的新图片作为BackButtonBackgroundImage,再在第三行设置title的位置偏移到一个不可见的位置,达到隐藏的目的。另外,如果需要全部统一替换,也可以在app的didFinishLaunching里通[UIBarButtonItem appearance]全部统一替换!)
UIImage* image = [UIImage imageNamed:@"back_button.png"]; [item setBackButtonBackgroundImage:[image resizableImageWithCapInsets:UIEdgeInsetsMake(0, image.size.width, 0, 0)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [item setBackButtonTitlePositionAdjustment:UIOffsetMake(-400.f, 0) forBarMetrics:UIBarMetricsDefault]; self.navigationItem.backBarButtonItem = item;
相关文章推荐
- storyboard进阶教程 搭建完整APP
- FindBugs初探
- JQuery选择标签小结
- U3D系列第二套教学视频上线--协程和异步加载
- JPA概要
- Range Sum Query 2D - Immutable My Submissionsstion-leetcode
- UIScrollViewDelegate - scrollViewDidEndDecelerating
- 快速上手git gitlab协同合作
- Uncaught TypeError: Cannot set property 'innerHTML' of null
- jquery 选择器
- 数据结构考研复习要点2016
- 关于dyld: Library not loaded Reason: image not found
- MVC设计模式
- 从 NSURLConnection 到 NSURLSession
- 二叉排序树
- Hive提交任务内存不足
- 工作中遇到的java 内存溢出,问题排查
- System.nanoTime与System.currentTimeMillis的区别
- 俄罗斯套娃
- QT出现 Cannot create children for a parent that is in a different thread 的解决方法: