美文网首页
iOS 图片中间拉伸,两边不拉伸

iOS 图片中间拉伸,两边不拉伸

作者: 起床赚钱了 | 来源:发表于2021-09-16 18:25 被阅读0次
    - (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];
    }
    

    相关文章

      网友评论

          本文标题:iOS 图片中间拉伸,两边不拉伸

          本文链接:https://www.haomeiwen.com/subject/zfqdgltx.html