UIImage

 UIImage *image = [UIImage imageNamed:@"message_i"];
//对图片进行切分
    image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(16, 16, 16, 30) resizingMode:UIImageResizingModeStretch];
    _imageView.image = image
 
// [self setClipsToBounds:YES];
        if ([[[UIDevice currentDevice]systemVersion] floatValue] >=6) {
            [[UITabBar appearance] setShadowImage:[[UIImage alloc]init] ]; 去掉tabor 的阴影线
        }
 
 
 
UIImage *image = [UIImageimageNamed:@"icon80"];
//以下两行代码可以省略不写...
    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(10, 10, 80, 80)];
//按照path勾勒的路径,将该区域以外的部分设置为绘制无效区域
    [path addClip];
//以上两行代码可以省略不写...
    [image drawInRect:CGRectMake(10, 10, 80, 80)];
<code class="hljs" objectivec="">    self.view.backgroundColor = [UIColor darkGrayColor];
 
    //不设置拉伸点,直接设置
    UIImage *image1 = [UIImage imageNamed:@QQ];
    UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 100, 170, 170)];
    imageView1.image = image1;
    [self.view addSubview:imageView1];
 
    //设置拉伸点,对左边和上面分开设置,理解其拉伸效果
    UIImage *image2 = [UIImage imageNamed:@QQ];
    image2 = [image2 stretchableImageWithLeftCapWidth:0 topCapHeight:image2.size.height*0.5];
    UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(190, 100, 170, 170)];
    imageView2.image = image2;
 
    [self.view addSubview:imageView2];</code>
 
 
 
<code class="hljs" objectivec="">    //不设置拉伸点,直接设置
    UIImage *image1 = [UIImage imageNamed:@chat];
    UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 200, 80)];
    imageView1.image = image1;
    [self.view addSubview:imageView1];


    //设置拉伸点
    UIImage *image2 = [UIImage imageNamed:@chat];
    image2 = [image2 stretchableImageWithLeftCapWidth:image2.size.width*0.5 topCapHeight:image2.size.width*0.8];
    UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(100, 200, 200, 80)];
    imageView2.image = image2;
    [self.view addSubview:imageView2];</code>
 
 
 
IImage * image =[[UIImage imageNamed:@"anim_loading_01"] stretchableImageWithLeftCapWidth:3.4 topCapHeight:23.0];
 
stretchableImageWithLeftCapWidth:3.4 topCapHeight:23.0
stretchableImageWithLeftCapWidth:表示横向拉伸 0 表示不拉伸
topCapHeight:表示竖向拉伸 0 表示不来伸
一天一章
原文地址:https://www.cnblogs.com/hangman/p/5463874.html