ios中拉伸图片的方法

来源:互联网 发布:淘宝运营计划书 编辑:程序博客网 时间:2024/05/31 18:31
 //下面有三种方法来拉伸图片    //    1.    //    [normal stretchableImageWithLeftCapWidth:normal.size.width * 0.5 topCapHeight:normal.size.height * 0.5];    //    2.CGFloat top上面保留多少,<#CGFloat left#>左边保留多少    //    CGFloat w = normal.size.width * 0.5;    //    CGFloat h = normal.size.height * 0.5;    //    [normal resizableImageWithCapInsets:UIEdgeInsetsMake(h, w, h, w)];    //    3.UIImageResizingMode填充图片的模式,UIImageResizingModeStretch:拉伸  UIImageResizingModeTile:平铺;    //    normal resizableImageWithCapInsets:UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>) resizingMode:(UIImageResizingModeTile);

// 注意:拉伸完图片以后,还必须要赋值,因为拉伸完并没有改变原来的图
如1.中

    UIImage * normal = [UIImage imageName:@”hehe”]; normal = [normal stretchableImageWithLeftCapWidth:normal.size.width * 0.5 topCapHeight:normal.size.height * 0.5];
0 0
原创粉丝点击