setValue: forKeyPath:
2015-08-07 10:59
225 查看
通过 setValue: forKeyPath:
这个方法来设置一些属性信息
此处的KeyPath所填写的内容有一个特点,首先是你想要修改的控件里面有这个分支,像UITextField里面就包含placeholderLabel,然后就是针对Label的属性,所以就得到了keyPath的内容“_placeholderLabel.textColor”
要是以后有些控件的一些信息无法改变的时候,你可以考虑用一下这个方法来尝试一下
继续上面的内容,一下是设置UITextField一边圆角一边直角的方法
这个方法来设置一些属性信息
<span style="font-size:18px;"> UITextField *textfield = [UITextField new]; [textfield setValue:[UIColor redcolor] forKeyPath:@"_placeholderLabel.textColor"]; [self setUIRectCorner:textfield</span><span style="font-size:18px;">]; [self.view addSubview:textfield]; </span>
此处的KeyPath所填写的内容有一个特点,首先是你想要修改的控件里面有这个分支,像UITextField里面就包含placeholderLabel,然后就是针对Label的属性,所以就得到了keyPath的内容“_placeholderLabel.textColor”
要是以后有些控件的一些信息无法改变的时候,你可以考虑用一下这个方法来尝试一下
继续上面的内容,一下是设置UITextField一边圆角一边直角的方法
<span style="font-size:18px;">- (void)setUIRectCorner:(UIView*)view { UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerBottomLeft cornerRadii:CGSizeMake(10.0, 10.0)];//10.是给圆角的设置 CAShapeLayer *maskLayer = [CAShapeLayer layer]; CAShapeLayer *borderLayer =[CAShapeLayer layer]; borderLayer.path = maskPath.CGPath; borderLayer.fillColor = [UIColor clearColor].CGColor; borderLayer.strokeColor = [UIColor orangeColor].CGColor; borderLayer.lineWidth = 1.5; borderLayer.frame =view.bounds; maskLayer.path = maskPath.CGPath; view.layer.mask = maskLayer; [view.layer addSublayer:borderLayer]; } //线面图片就是展示效果以及附带代码 </span>
相关文章推荐
- 浅谈:UEO就是SEO的一种
- Android 重写系统控件UI,自定义进度条
- 超详细!iOS 并发编程之 Operation Queues
- druid连接无法回收...
- 解决 UITextView 没有 ShouldReturn 事件
- iOS之整型转换警告Values of type 'NSInteger' should not be used as format arguments;
- Language Guide (proto3)
- UIScrollView 原理详解
- Fruit
- editui刷新数据与列表循环
- easyui阻止事件冒泡
- amazeui 懒加载 搜索不到图片时,如何为图片加上默认图
- 23. PHP include and require 文件
- EQueue性能测试计划
- NGUI 九宫格纹理拉伸
- Bluetooth Keyboard Replace
- Handler、Looper、MessageQueue(三)
- 哈希-4 Values whose Sum is 0
- 哈希-4 Values whose Sum is 0 分类: POJ 哈希 2015-08-07 09:51 3人阅读 评论(0) 收藏
- leetcode_Implement Stack using Queues