xcode 如何在目标 c 中对齐左 UIImage
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10083663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:56:03 来源:igfitidea点击:
how to align left UIImage in objective c
提问by user1323273
- (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;
}
回答by Ravi
UIImageView *titleLabel = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nature.jpeg"]];
titleLabel.frame = CGRectMake(0, 0, 120, 40);
titleLabel.contentMode = UIViewContentModeRight;
self.navigationItem.titleView = titleLabel;
回答by nembleton
I think the best is to use UIImageView contentMode property.
我认为最好的方法是使用 UIImageView contentMode 属性。
You can use like this:
你可以这样使用:
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)];
imageView.contentMode = UIViewContentModeLeft;
It should be ok.
应该没问题。