首页 > 移动平台 > 详细

IOS开发教程--怎样使用点9图片

时间:2017-06-13 19:35:07      阅读:455      评论:0      收藏:0      [点我收藏+]

事先准备一张图片:技术分享


UIImage *image = [UIImage imageNamed:@"red.png"];

    在iOS 5.0之前能够这么用:

    NSInteger leftCapWidth = image.size.width * 0.5f;

    NSInteger topCapHeight = image.size.height * 0.5f;

    image = [image stretchableImageWithLeftCapWidth:leftCapWidth topCapHeight:topCapHeight];


在iOS 5.0中能够这么用:

    CGFloat top = 8;// 顶端盖高度

   CGFloat bottom = 8; // 底端盖高度

    CGFloat left = 8; // 左端盖宽度

   CGFloat right = 8;// 右端盖宽度

    UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);

    // 伸缩后又一次赋值

    image = [image resizableImageWithCapInsets:insets];

在iOS6.0中能够这么用:

   CGFloat top = 12; // 顶端盖高度

    CGFloat bottom = 12 ; // 底端盖高度

    CGFloat left = 10; // 左端盖宽度

    CGFloat right = 10; // 右端盖宽度

    UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);

    // 指定为拉伸模式,伸缩后又一次赋值

    image = [image resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];




IOS开发教程--怎样使用点9图片

原文:http://www.cnblogs.com/yxysuanfa/p/7002995.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!