button背景图片拉伸不变形

  • (UIImage ) resizableImage:(NSString ) imageName {
    UIImage image = [UIImage imageNamed:imageName];
    // 取图片底部的1 x 1进行拉伸 中部是/2
    UIEdgeInsets insets = UIEdgeInsetsMake(image.size.height
    4/5, image.size.width
    4/5, image.size.height
    4/5 + 1, image.size.width*4/5 + 1);

    return [image resizableImageWithCapInsets:insets];
    }

你可能感兴趣的:(button背景图片拉伸不变形)