In UIView subclass init method I have this piece:
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; should center image, but still it shows up in top left corner. What am I doing wrong?
EDIT: Sorry, i found answer myself. thanks to everyone
Your myImage size is equal to the size of imageView. To see the difference make your myImage size a bit smaller than that of imageView.After that it will be centered. In your one line change the size of image :