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

      

      

  • 相关阅读:
    SICP 习题1.16-1.19体会
    设计模式C++实现——组合模式
    QT官方下载地址
    浅析三角形測试程序
    操作系统开发之——进入保护模式
    PowerDesigner 打印错误
    @RequestParam注解一般用法
    Eclipse配置Maven的一些问题
    在windows上部署使用redis出现的问题及解决方法
    Eclipse导入模板格式Xml配置文件
  • 原文地址:https://www.cnblogs.com/saytome/p/6964779.html
Copyright © 2011-2022 走看看