开发者

what's the preferred visibility toggle for UIImage (like setHidden on UIButton)?

开发者 https://www.devze.com 2022-12-23 09:09 出处:网络
I\'d like to control visibility on a simple UI element. If it was a button, I\'d just call setHi开发者_Python百科den on it, but UIImage has no such method.

I'd like to control visibility on a simple UI element. If it was a button, I'd just call setHi开发者_Python百科den on it, but UIImage has no such method.

What's the preferred way of showing or hiding an image? Just making it a UIButton and not hooking it up to any methods seems wasteful.. is that really the right way to do it?


Shouldn't your image be in an image view?

UIImageView imageView = [[UIImageView alloc] initWithImage:myImage];

Then you can hide the image view with:

imageView.hidden = YES;


hidden is a property of UIView, so you can use it with UIImageViews.

0

精彩评论

暂无评论...
验证码 换一张
取 消