What code for the iPhone so the user can change the font size in text view by clicking some buttons?
How do I impl开发者_StackOverflowement code for the iPhone so the user can change the font size in text view by clicking some buttons? (UITextView usage)
Wire up the buttons to IBActions. Create your interface with an outlet for your UITextView (textView
) and the current font size (fSize
).
Within the IBAction put this code:
- (IBAction) fontPlusDown {
fSize++;
UIFont *newFont = [UIFont systemFontOfSize:fSize];
[textView setFont:newFont];
}
Adjust the code for reduction (fSize--).
Use [textView setFont:[UIFont fontWithSize:yourdesiredSize]]
when you tap on a button.
精彩评论