over 8 years ago
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;
}
- (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.
Can you help out the community by solving one of the following SEO & Growth Hacking problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)