zoukankan      html  css  js  c++  java
  • iOS 用keypath设置一些属性

    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"];
    

      

      

  • 相关阅读:
    python起航
    【Git】rebase 用法小结
    使用AutoJs编写UI的踩坑记录
    cpu性能消耗分析
    python自动安装依赖模块_python模块管理:如何自动生成和安装requirements.txt依赖...
    Office Tools Plus
    Git 仓库基础操作
    jmeter-阶梯式压测
    JMeter ServerAgent服务器资源监控插件
    Fastjson 从JSON字符串中取值 操作示例
  • 原文地址:https://www.cnblogs.com/saytome/p/6964779.html
Copyright © 2011-2022 走看看