Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Left padding to the TextField

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 451
    Comment on it

    Whenever we use TextField then bydefault we don't get front space. Sometimes we want that our text should start after some gap so in that case we can use padding. In padding we can give space according to our need. There are two types of padding -: Left and right padding.

    Left Padding-> left padding means give left space to the TextField, so that text should start after some gap from the left side.

    Right Padding-> Right padding means give right space to the text field, so that text should end before some gap from the right side.

     Below code is used to provide left padding to the TextField.

    - (void)leftPaddingToTextField:(UITextField *)textField{
        UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
        textField.leftView = paddingView;
        textField.leftViewMode = UITextFieldViewModeAlways;
    }

    Here we have taken a variable of type UIView and allocated memory to it and size. We are basically adding view in the left or right side of the TextField.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: