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

      

      

  • 相关阅读:
    Leetcode53_Spiral_Matrix
    leetcode 分类
    bash 脚本
    关闭占用端口
    blue bossa
    判断对称二叉树
    This server is in the failed servers list: localhost/127.0.0.1:16000 启动hbase api调用错误
    在cikuapi.com上抓取相关词
    那些天使用AWS填过的坑和注意事项
    一百个人的十年-读后感
  • 原文地址:https://www.cnblogs.com/saytome/p/6964779.html
Copyright © 2011-2022 走看看