zoukankan      html  css  js  c++  java
  • 给UITextField设置头或尾空白

    有时候,我们需要在UITextField的头尾加入一些空白,如下图所示:

    其中,黄色和红色部分代表空白。

    实现起来,比较简单,只需要设置UITextField的leftView、leftViewMode和rightView、rightViewMode即可,代码如下:

    假设现有UItextField * txtField;

        UIView * rView =[[UIView alloc] initWithFrame:CGRectMake(txtField.frame.size.width - 10, 0, 10, txtField.frame.size.height)];
        rView.backgroundColor = [UIColor redColor];
        txtField.rightView = rView;
        txtField.rightViewMode = UITextFieldViewModeAlways;
        UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, txtField.frame.size.height)];
        view.backgroundColor = [UIColor yellowColor];
        txtField.leftViewMode = UITextFieldViewModeAlways;
        txtField.leftView = view;
  • 相关阅读:
    QuickContactBadge
    第一周——15选1
    UVA 10036 Divisibility
    POJ 3984 迷宫问题
    POJ 3258 River Hopscotch
    CodeForces 230A Dragons
    HDU 4450 Draw Something
    POJ 2485(PRIME算法)
    HDU 1213
    CodeForces 16E
  • 原文地址:https://www.cnblogs.com/benbenzhu/p/3796513.html
Copyright © 2011-2022 走看看