嗨,谢谢你花时间看我的问题
我有一个逻辑问题,我有一个信息按钮,按下时会更改UI图像视图中的图像
- (IBAction)infopressed:(id)sender {
useridtext.hidden = YES;
password.hidden = YES;
//the original image before change is called 'login alpa'
CATransition *animation = [CATransition animation];
animation.duration = 2.0;
animation.type = kCATransitionFade;
animation.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseIn];
[_login.layer addAnimation:animation forKey:@"changeImageTransition"];
// change image
_login.image = [UIImage imageNamed:@"imageciren1.jpeg"];
}
如何将图像视图中的图像更改回登录alpha?如果他们按下按钮将其更改为imageciren1等。
答案 0 :(得分:0)
- (IBAction)infopressed:(id)sender {
static int = 0;
NSString *imageName;
if (i == 1) {
imageName = @"loginalpha.jpeg";
useridtext.hidden = NO;
password.hidden = NO;
i--;
} else {
imageName = @"imageciren1.jpeg";
useridtext.hidden = YES;
password.hidden = YES;
i++;
}
CATransition *animation = [CATransition animation];
animation.duration = 2.0;
animation.type = kCATransitionFade;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[_login.layer addAnimation:animation forKey:@"changeImageTransition"];
// change image
_login.image = [UIImage imageNamed:imageName];
}
答案 1 :(得分:0)
- (IBAction)infopressed:(id)sender {
if (contactlabel.text.length)
[contactlabel setText:@""];
else
[contactlabel setText:@"Test"];
}