我正在尝试以这种方式每 1.5 秒更改一次 UItextField 上的文字:
-(void)Welcome{
UITextField* WelcomeField = [[UITextField alloc] initWithFrame:CGRectMake(50,230,220,80)];
[self.view addSubview:WelcomeField];
WelcomeField.placeholder = @"Welcome";
WelcomeField.font = [UIFont fontWithName:@"Chalkduster" size:40];
[WelcomeField setBackgroundColor:[UIColor clearColor]];
NSTimer* TimeCounterWelcome = [NSTimer scheduledTimerWithTimeInterval: 1.5 target: self
selector: @selector(ChangeLanguage:) userInfo: nil repeats: YES];
}
- (IBAction)ChangeLanguage:(id)sender{
WelcomeField.placeholder = @"Goodby";
NSTimer* TimeCounterWelcome = [NSTimer scheduledTimerWithTimeInterval: 1.5 target: self
selector: @selector(ChangeLanguage2:) userInfo: nil repeats: YES];
}
- (IBAction)ChangeLanguage2:(id)sender{
WelcomeField.placeholder = @"Friend";
}
问题是我有30个字,我不能重复代码30次。有更快的方法吗?