user1323273
user1323273

Reputation: 21

how to align left UIImage in objective c

- (void)viewDidLoad
{
   [super viewDidLoad];
   [self setTitle:@"myTitle"];
   UIImageView *titleLabel = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myImage.PNG"]];
   titleLabel.frame = CGRectMake(0, 0, 120, 40);
   self.navigationItem.titleView = titleLabel;
}

Upvotes: 0

Views: 8254

Answers (2)

Ravi Kumar Karunanithi
Ravi Kumar Karunanithi

Reputation: 2218

UIImageView *titleLabel = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nature.jpeg"]];
titleLabel.frame = CGRectMake(0, 0, 120, 40);
titleLabel.contentMode = UIViewContentModeRight;
self.navigationItem.titleView = titleLabel;

Upvotes: 5

nembleton
nembleton

Reputation: 2502

I think the best is to use UIImageView contentMode property.

You can use like this:

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)];
imageView.contentMode = UIViewContentModeLeft;

It should be ok.

Upvotes: 3

Related Questions