+ (UIImageView*)attachImageToView:(UIView*)viewObject withId:(NSString*)imgId andRect:(CGRect)rect {
UIImageView *img = [[UIImageView alloc] initWithFrame:rect];
img.image = [UIImage imageNamed:imgId];
[viewObject addSubview:img];
[img release];
return img;
}
A collection of handy code snippets in the languages that I use on a daily basis.
January 29, 2009
iPhone: Attach an image with one line of code
I got sick of the 4 lines of code it takes to attach and garbage collect a UIImageView to your UIView, so I wrote a static function for our DisplayUtil class to clean up this process. Check it out below and feel free to use:
Labels:
addsubview,
attach,
cocoa,
function,
objective-c,
static,
uiimageview,
uiview
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment