zoukankan      html  css  js  c++  java
  • UITextField

     

    关于UItextField的LeftView属性

        leftView属性赋值时 如果给两个textfield 同时设置这个属性  不能是同一个 View 如果是同一个View 这个页面就不能跳转

        UIView *leftSpaceView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, leftViewW, textFieldH)];

        leftSpaceView.backgroundColor = [UIColor whiteColor];

      

        UIView *leftSpaceViewSecond = [[UIView alloc] initWithFrame:CGRectMake(0, 0, leftViewW, textFieldH)];

        leftSpaceView.backgroundColor = [UIColor whiteColor];

        UITextField *phoneNum = [[UITextField alloc] initWithFrame:CGRectMake(spaceBetweenX, 65, KScreenW - spaceBetweenX*2, textFieldH)];

        phoneNum.tag = -15;

        phoneNum.leftView = leftSpaceView;

        phoneNum.leftViewMode = UITextFieldViewModeAlways;

        phoneNum.layer.borderWidth = 1.0;

        phoneNum.layer.borderColor = [UIColor colorWithHexString:@"#dadada" withAlpha:1].CGColor;

        phoneNum.placeholder = @"已注册手机号";

        [self.view addSubview:phoneNum];

        

        

        UITextField *newCode = [[UITextField alloc] initWithFrame:CGRectMake(spaceBetweenX, CGRectGetMaxY(phoneNum.frame) + 25, KScreenW  - spaceBetweenX*2 - phoneNum.bounds.size.width*1/3 - 10, textFieldH)];

        newCode.backgroundColor = [UIColor clearColor];

        newCode.layer.borderColor = [UIColor colorWithHexString:@"#dadada" withAlpha:1].CGColor;

        newCode.layer.borderWidth = 1.0f;

        newCode.leftView = leftSpaceViewSecond;

        newCode.leftViewMode = UITextFieldViewModeAlways;

        newCode.tag = -16;

        newCode.placeholder = @"请输入短信验证码";

        [self.view addSubview:newCode];

     

     

    placeholder的字体颜色、大小

    NSAttributedString *one = [[NSAttributedString alloc] initWithString:@"    官方自带" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:30]}];

    tureText.attributedPlaceholder = one;

    UITextField中文输入法输入时对字符长度的限制  想限制几位就写几

    - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {

        if ([textField isEqual:self.verifyField]) {

            if (range.location>=3)

                return NO;

            }

        }

      

        return YES;

    }

  • 相关阅读:
    系统设计的一些原则
    分层开发思想与小笼包
    工作与生活
    Microsoft .NET Pet Shop 4 架构与技术分析
    用人之道(二) 如何管理软件开发团队
    也谈很多开发人员的毛病
    《3S新闻周刊》第10期,本期策划:“超女”营销带来的启示
    浅析ArcIMS
    MapX的坐标问题
    应用ArcIMS构建GMap风格的地图应用
  • 原文地址:https://www.cnblogs.com/zhaozhongpeng/p/4867820.html
Copyright © 2011-2022 走看看