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

  • 相关阅读:
    ajax(读取json数据)
    MD5加密出现 无法启动:此实现不是Windows平台FIPS验证的加密算法的一部分
    二维码(android)
    电脑快捷键大全
    OkHttp
    HttpURLConnection 传输数据和下载图片
    子线程更新UI界面的2种方法
    URLConnection(互联网)
    点滴
    SQL 备忘录
  • 原文地址:https://www.cnblogs.com/yintingting/p/4569200.html
Copyright © 2011-2022 走看看