我有一个ipad应用程序,当用户执行某些操作时,uitextfields和按钮会从视图中显示和消失[正常工作]
[cancelBtn setHidden: true];
[lblOption setHidden:true];
问题是,如果有一些方法可以在它们出现和消失时进行动画处理,例如过渡,按钮的透明alpha,例如,
非常感谢!
答案 0 :(得分:0)
是。例如:
[UIView animateWithDuration:1 animations:^{
cancelBtn.alpha = 0;
}];
有关详细信息,请参阅the View Programming Guide for iOS。
答案 1 :(得分:0)
[self.view addSubview:btn5];
//
// [[txt1 layer] setBorderWidth:2.5f];
// [[txt1 layer ] setBorderColor:[UIColor blackColor].CGColor];
//
[self.view addSubview:txt1];
txt2=[[UITextField alloc] initWithFrame:CGRectMake(20,150,180 ,35)];
txt2.backgroundColor=[UIColor brownColor];
txt2.borderStyle=UITextBorderStyleRoundedRect;
txt2.textColor=[UIColor whiteColor];
txt2.adjustsFontSizeToFitWidth=YES;
txt2.backgroundColor=[UIColor clearColor];
// [[txt2 layer] setBorderWidth:2.5f];
// [[txt2 layer ] setBorderColor:[UIColor blackColor].CGColor];
//
[self.view addSubview:txt2];
txt3.userInteractionEnabled=NO;
// [btn2 setSelected:NO];
// [btn3 setSelected:NO];
// [btn4 setSelected:NO];
//
NSLog (@"Movie selected");
break;
case 2:
// [btn2 setSelected:YES];
txt3=[[UITextField alloc] initWithFrame:CGRectMake(20,110,180 ,35)];
txt3.backgroundColor=[UIColor brownColor];
txt3.borderStyle=UITextBorderStyleRoundedRect;
txt3.textColor=[UIColor whiteColor];
txt3.adjustsFontSizeToFitWidth=YES;
[self.view addSubview:txt3];
txt1.userInteractionEnabled=NO;
txt2.userInteractionEnabled=NO;
//
// [btn1 setSelected:NO];
// [btn3 setSelected:NO];
// [btn4 setSelected:NO];
NSLog (@"Play selected");
break;
case 3:
// [btn3 setSelected:YES];
//
//
//
// [btn1 setSelected:NO];
// [btn2 setSelected:NO];
// [btn4 setSelected:NO];
//
NSLog (@"Events selected");
break;
default:
// [btn4 setSelected:YES];
//
// [btn1 setSelected:NO];
// [btn2 setSelected:NO];
// [btn3 setSelected:NO];
NSLog (@"Sports selected");
break;
}
}
-(IBAction)radioButton:(id)sender
{
switch ([sender tag]) {
case 0:
[rbtn1 setSelected:YES];
[rbtn2 setSelected:NO];
NSLog(@"Movies Selected");
break;
case 1:
[rbtn2 setSelected:YES];
[rbtn1 setSelected:NO];
NSLog(@"Cinemas Selected");
// if ([rbtn1 isSelected]==YES) {
// [rbtn1 setSelected:NO];
// [rbtn2 setSelected:YES];
// } else {
// [rbtn1 setSelected:YES];
// [rbtn2 setSelected:NO];
// }
//
// break;
// case 1:
// if ([rbtn2 isSelected]==YES) {
// [rbtn2 setSelected:NO];
// [rbtn2 setSelected:YES];
// } else {
// [rbtn2 setSelected:YES];
// [rbtn2 setSelected:NO];
// }
default:
break;
}
}