首页 > 移动平台 > 详细

iOS 用keypath设置一些属性

时间:2017-06-08 22:07:26      阅读:508      评论:0      收藏:0      [点我收藏+]

1.UIButton title 距左边显

button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;

  

  

2.UITextField placeholder 颜色

方法一:

textField.placeholder = @"this is placeholder";  
[textFieldsetValue:[UIColor redColor]forKeyPath:@"_placeholderLabel.textColor"];  
[textFieldsetValue:[UIFontboldSystemFontOfSize:16]forKeyPath:@"_placeholderLabel.font"]; 

  

方法二:(iOS 6 之后)

NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc]initWithString:@"this is placeholder"];

[placeholderaddAttribute:NSForegroundColorAttributeName
                  value:[UIColor redColor]
                  range:NSMakeRange(0, placeholder.length)];

[placeholderaddAttribute:NSFontAttributeName
                  value:[UIFontboldSystemFontOfSize:14]
                  range:NSMakeRange(0, placeholder.length)];


textField.attributedPlaceholder = placeholder;

 

3.隐藏 tabBar 顶部的分割线

[self.tabBar setValue:@(YES) forKeyPath:@"_hidesShadow"];

  

  

iOS 用keypath设置一些属性

原文:http://www.cnblogs.com/saytome/p/6964779.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!