开发者

UIImage from UIView to UIViewController

I am creating a UIImage programmatically in my UIView's drawRect function. Is there a way that the UIViewController responsible for this UIView access that image (or开发者_StackOverflow社区 a copy of it) for manipulation?

Appreciate any pointers and thanks in advance.


If your UIImage you create programmatically in your drawrect is stored as a property on the UIView subclass, then the UIViewController can access the image.

Obviously, if you are using Interface Builder you'd need to wire up your UIView subclass to an IBOutlet on the UIViewController class to access the property, but I'm sure you're doing that already.

e.g. in the drawrect function

self.storedImage = [[UIImage alloc] init... ];

in the header for the UIView subclass
UIImage* storedImage;

@property (nonatomic, retain) UIImage* storedImage;

The nonatomic retained property ensures that you're not leaking UIImages each time the draw rect function is called.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜