在我的主 Storyboard中,我有一个带有隐藏的 UIImageView
的 UIViewController
。我在一个线程中读到要使图像淡出我可以使用以下代码。我想知道如何将我创建的 UIImageView
与 IBAction
联系起来。
-(IBAction)popupImage
{
_imageView.hidden = NO;
_imageView.alpha = 1.0f;
// Then fades it away after 2 seconds (the cross-fade animation will take 0.5s)
[UIView animateWithDuration:0.5 delay:2.0 options:0 animations:^{
// Animate the alpha value of your imageView from 1.0 to 0.0 here
_imageView.alpha = 0.0f;
} completion:^(BOOL finished) {
// Once the animation is completed and the alpha has gone to 0.0, hide the view for good
_imageView.hidden = YES;
}];
}
我是否创建一个连接到图像的 @property(强,非原子)IBOutlet UIImageView *imageView;
?
最佳答案
您正在使用 Storyboard,因此请按住 Control 键将 UIImageView 拖到您的界面中。该属性不需要很强——它应该是:@property (weak, nonatomic) IBOutlet UIImageView *imageView
。
如果您不知道如何控制拖动,此视频可能会有所帮助:https://www.youtube.com/watch?v=xq-a7e_l_4I .快进到 2:05。
关于ios - UIImageView淡出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25209678/