将UIView的子类变为圆形的简单实现方式(圆形头像、圆形按钮)

    UIView *roundview = [[UIView alloc]init];

    [roundview.layer setCornerRadius:CGRectGetHeight([roundview bounds]) / 2];

    roundview.layer.masksToBounds = YES;

    roundview.layer.borderWidth = 5;//边框width

    roundview.layer.borderColor = [[UIColor whiteColor] CGColor];//边框color

    roundview.layer.contents = (id)[[UIImage imageNamed:@"backgroundImage.png"] CGImage];

你可能感兴趣的:(圆形View)