实现圆形头像

原创
2014/03/28 16:11
阅读数 478
#import "ViewController.h"
@interface  ViewController ()
@end 
@implementation ViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    UIImageView *ivAvatar = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetWidth([self.view bounds]) / 2 - 50, 40, 100, 100)];
    ivAvatar.image = [UIImage imageNamed:@"avatar.jpg"];
    ivAvatar.layer.masksToBounds = YES;
    [ivAvatar.layer setCornerRadius:CGRectGetHeight([ivAvatar bounds]) / 2];
    ivAvatar.layer.borderWidth = 5;
    ivAvatar.layer.borderColor = [[UIColor whiteColor] CGColor];
    [self.view addSubview:ivAvatar];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
@end


展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部