如何使用uitextView更改分段控件中使用的文本的颜色和大小,其中textView是插座
这是.h文件
@interface MainViewController : UIViewController <UIActionSheetDelegate>
{
IBOutlet UISegmentedControl * control;
IBOutlet UITextView *textView;
}
-(IBAction)switchcontrol:(id)sender;
这是.m文件代码
-(IBAction)switchcontrol:(id)sender {
if (control.selectedSegmentIndex == 0) {
[textView.layer setBackgroundColor: [[UIColor whiteColor] CGColor]];
[textView.layer setBorderColor: [[UIColor grayColor] CGColor]];
[textView.layer setBorderWidth: 1.0];
[textView.layer setCornerRadius:8.0f];
[textView.layer setMasksToBounds:YES];
textView.text = @"This is text 1";
}
if (control.selectedSegmentIndex == 1) {
[textView.layer setBackgroundColor: [[UIColor whiteColor] CGColor]];
[textView.layer setBorderColor: [[UIColor grayColor] CGColor]];
[textView.layer setBorderWidth: 1.0];
[textView.layer setCornerRadius:8.0f];
[textView.layer setMasksToBounds:YES];
textView.text = @"This is text 2";
}
}