iOS UIImageView图片自动拉伸功能
更新:HHH   时间:2023-1-8


本文实例为大家分享了iOS图片自动拉伸的具体代码,供大家参考,具体内容如下

这个是使用一个切片,使其填充到整个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实现这种效果,这个下次再说。

先上图:

切片如下:

有图有真相:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持天达云。

返回移动开发教程...