在UIView子類的init方法我有這片:不能居中圖像中的UIImageView編程
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 44, 320, 436)];
imageView.contentMode = UIViewContentModeCenter;
[self addSubview:imageView];
UIImage* myImage = [UIImage imageWithData:
[NSData dataWithContentsOfURL:
[NSURL URLWithString: imageSource]]];
myImage = [[MyMath sharedMySingleton] imageWithImage:myImage convertToSize:CGSizeMake(320, 436)]; // resizes image to set bounds
imageView.contentMode = UIViewContentModeCenter;
[imageView setImage:myImage];
imageView.contentMode = UIViewContentModeCenter;
要圍繞圖像,但它仍然在左上角顯示出來。我究竟做錯了什麼?
編輯:對不起,我發現自己的答案。感謝大家
嗨,你能分享你的答案嗎? – 2013-03-19 12:17:52