在 UIView 子类 init 方法中,我有这个:
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;
应该居中图像,但它仍然显示在左上角。我究竟做错了什么?
编辑:对不起,我自己找到了答案。谢谢大家