设为首页 加入收藏

TOP

【代码笔记】iOS-使图片两边不拉伸,中间拉伸
2017-10-13 10:28:34 】 浏览:9614
Tags:代码 笔记 iOS- 图片 两边 拉伸 中间

代码:

复制代码
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //使图片两边不拉伸,中间拉伸
    UIImage *image = [UIImage imageNamed:@"1.jpg"];
    image = [image stretchableImageWithLeftCapWidth:floorf(image.size.width/2) topCapHeight:floorf(image.size.height/2)];
    
    UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(50, 100, 200, 200)];
    imageView.backgroundColor=[UIColor redColor];
    imageView.image=image;
    [self.view addSubview:imageView];
}
复制代码

 

 

 
 
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Label自适应高度 下一篇创建Podspec 并且发布到github sp..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目