UIImageView设置为圆形

  

  CGFloat headimageX = self.view.frame.size.width * 0.2;

    CGFloat headimageY = self.view.frame.size.height * 0.25;

    CGFloat headimageW = self.view.frame.size.width * 0.6;

    CGFloat headimageH = headimageW;

    UIImageView *headimageview  = [[UIImageView alloc] init];

    headimageview.frame = CGRectMake(headimageX, headimageY, headimageW, headimageH);

    //这句必须写

    headimageview.layer.masksToBounds = YES;

    headimageview.layer.cornerRadius = headimageW * 0.5;

    headimageview.image = [UIImage imageNamed:@"1"];

    [self.view addSubview:headimageview];

posted @ 2015-11-23 15:52  偏执Dog  阅读(461)  评论(0编辑  收藏  举报