zoukankan      html  css  js  c++  java
  • UITextfield

     1.光标颜色

    textf.tintColor

    光标位置

    设置leftView来控制

    2.文本框聚焦时调用的方法

    - (BOOL)becomeFirstResponder

     3. 设置默认的占位文字颜色

     第一种

      [self setValue:[UIColor grayColor] forKeyPath:@"placeholderLabel.textColor"];

    第二种

    - (void)drawPlaceholderInRect:(CGRect)rect
    {
        // 文字属性
        NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
        attrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
        attrs[NSFontAttributeName] = self.font;
        
        // 画出占位文字
    //    CGRect placeholderRect;
    //    placeholderRect.size.width = rect.size.width;
    //    placeholderRect.size.height = self.font.lineHeight;
    //    placeholderRect.origin.x = 0;
    //    placeholderRect.origin.y = (rect.size.height - self.font.lineHeight) * 0.5;
    //    [self.placeholder drawInRect:placeholderRect withAttributes:attrs];
        
        CGPoint placeholderPoint = CGPointMake(0, (rect.size.height - self.font.lineHeight) * 0.5);
        [self.placeholder drawAtPoint:placeholderPoint withAttributes:attrs];
    }

     4.当textfiled变为第一响应者时,改变占位字符的颜色

    第一种方法

        重写- (BOOL)becomeFirstResponder

    第二种方法

        taget-sel  监听状态:

    UIControlEventEditingDidBegin

    第三种方法

      设置代理为self,实现代理方法

    5.字体的高度

    self.font.lineHeight

  • 相关阅读:
    javap -c 字节码含义
    redis --- lua 脚本实现原子操作
    感想
    AbstractAdvisingBeanPostProcessor---spring aop 处理器
    spring 自定义解析类
    protobuf3 语法解析
    Java设计模式之builder模式
    工厂和抽象工厂模式
    RESTful入门
    RocketMQ入门
  • 原文地址:https://www.cnblogs.com/yintingting/p/4569200.html
Copyright © 2011-2022 走看看