【问题标题】:Dynamic underline for JVfloatLabel Text field library?JVfloatLabel 文本字段库的动态下划线?
【发布时间】:2018-01-06 05:33:31
【问题描述】:

我刚刚开始研究目标 c。在我的一个项目中,我实现了一个库,如下面的链接所示。

https://github.com/jverdi/JVFloatLabeledTextField

我想知道是否有任何方法可以在文本字段中实现下划线,如下面的链接所示。

https://github.com/Skyscanner/SkyFloatingLabelTextField/blob/master/SkyFloatingLabelTextField/images/showcase-example.gif

提前致谢。

【问题讨论】:

    标签: ios objective-c textfield


    【解决方案1】:

    textfield点击

    -(void)viewWillAppear:(BOOL)animated{
          [textfieldname addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
    }
    

    返回Textfiled换色

    - (void)textFieldDidChange:(UITextField *)textfield{
        CALayer *border = [CALayer layer];
        CGFloat borderWidth = 2;
        border.borderColor =[UIColor colorWithRed:111.0f/255.0f green:111.0f/255.0f blue:111.0f/255.0f alpha:1.0].CGColor;
        border.frame = CGRectMake(0, textfield.frame.size.height - borderWidth, textfield.frame.size.width, textfield.frame.size.height);
        border.borderWidth = borderWidth;
        [textfield.layer addSublayer:border];
        textfield.layer.masksToBounds = YES;
    }
    

    https://stackoverflow.com/a/15489967/9137841检查这个可能对你有帮助

    【讨论】:

    • 谢谢!你的回答给了我一个大概的思路。
    猜你喜欢
    • 2018-04-29
    • 2020-12-11
    • 2014-08-22
    • 2012-01-03
    • 1970-01-01
    • 2011-06-08
    • 1970-01-01
    • 2013-08-22
    • 1970-01-01
    相关资源
    最近更新 更多