开发者

iPhone Sdk: Is it possible to add an UIImageView as a file?

i was just wondering wether it is possible to add an uiimageview as a .m and .h class file because you can just choose a subclass from uiview or uitableviewcell in apple's templates and it than au开发者_如何学运维tomatically creates the .m and .h files. Is there a way to do the same for an UIImageView or is it possible to somehow "turn" the UIView into an imageview?

thanks in advance!


You could create you own subclass of UIImageView, yes. And if you're very brave, you could also create your own subclass of UIView as well, that would take a UIImage and paint that in it's -(void)drawRect: method. Then it would be much like a UIImageView.

But, why would you?

edit subclassing UIImageView is easiest by starting with the UIView subclass template, and then just replacing the word UIView with UIImageView, so you get:

@interface UIImageViewPlus : UIImageView {
    // ...
}

That's all there is to it, now just use UIImageViewPlus wherever you would use UIImageView.


UIImageView is a UIView since it inherits directly from UIView so I'm not sure what you are asking about.....you can easily create a subclass of the UIImageView to do whatever customization you require....

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜