這裏是我的形象:如何使我的圖像中的中心IOS水平
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)];
取決於圖像大小我無法弄清楚如何居中,任何想法?
這是所有裏面的方法:
- (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);
}
凡rect.size.width
打印320.000000和rect.size.height
打印416.000000
嗯......有沒有保證的寬度的一個部門或2個住宿爲整數的高度。我會加上'地板'。 – 2013-01-22 16:09:51