Here is my image :
Obj *obj = ... obj has imageHref which is NSString
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:obj.imageHref]];
[image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
Depending on image size I can't figure out how to center it, any ideas ?
This is all inside method :
- (void)drawRect:(CGRect)rect {
Obj *obj = ... obj has imageHref which is NSString
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:obj.imageHref]];
[image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
NSLog(@"%f", rect.size.width);
NSLog(@"%f", rect.size.height);
}
Where rect.size.width
prints 320.000000 and rect.size.height
prints 416.000000
Best Answer
edit:
As you are already in a UIView: