Reputation: 25751
I have the following code in my uiviewcontroller that is embed in a uinavigationcontroller.
In viewDidLoad:
[self addLogo];
Below:
- (void) addLogo
{
UIImage *image = [UIImage imageNamed:@"logoblack.png"];
UIImageView *myImageView = [[UIImageView alloc] initWithImage:image];
myImageView.frame = CGRectMake(0, 0, 30, 30);
myImageView.layer.cornerRadius = 5.0;
myImageView.layer.masksToBounds = YES;
myImageView.layer.borderColor = [UIColor lightGrayColor].CGColor;
myImageView.layer.borderWidth = 0.1;
self.navigationItem.titleView = myImageView;
}
The image I have is 434 by 434 but I want it to be 30 by 30. Instead it is streched and overtakes my < Back button in the navigation bar. Is there a scale method?
Upvotes: 1
Views: 144
Reputation: 1678
use
myImageView.contentMode = UIViewContentModeScaleAspectFill;
so that the imageview will not be streched , and keep its aspect
Upvotes: 3