IOS_UIImageView图片自动拉伸

来源:互联网 发布:verilog 数组 编辑:程序博客网 时间:2024/05/02 07:49

这个是使用一个切片,使其填充到整个NavigationBar上面。

- (void)viewDidLoad{    [super viewDidLoad];        UIImage *smallImage = [UIImage imageNamed:@"hc_03.png"];      UIImageView *imageView = [[UIImageView alloc] initWithImage:smallImage];    [imageView setFrame:CGRectMake(0, 20, 320, 44)];    imageView.contentMode = UIViewContentModeScaleToFill;    [self.view addSubview:imageView];    [imageView release];     }


这里采用的是使用addSubView的方法遮住原来的NavigationBar,其实还有别的方法,可以使用重绘NavigationBar实现这种效果,这个下次再说。

先上图:
切片如下:

有图有真相: