将图片修正为圆形

 

    UIImageView * imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"oiuyfdsa.png"]];

    imageView.frame = CGRectMake(20.f, 20.f, 100.f, 100.f);

    imageView.layer.masksToBounds = YES;

    imageView.layer.cornerRadius = 50;

注意:

1、该方法需要导入QuartzCore框架

#import <QuartzCore/QuartzCore.h>

2、cornerRadius的值为图片尺寸的一半

 

再注意:

虽然这种方法可以很方便地将图片设置为圆角,但是需要进行浮点运算,如果图片较少,是一种不错的选择,如果用在列表中,可能会导致性能下降,有卡顿感觉,此时可以找美工帮忙。

你可能感兴趣的:(图片)