将图像设置成圆形

//将图形设置成圆形

    //初始化并设label frame

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];

    //设置四角的半径 cornerRadius

    label.layer.cornerRadius = label.frame.size.width / 2;

    //剪切多余边界

    label.clipsToBounds = YES;

    //设置圆边界圆形的宽

    label.layer.borderWidth = 3.0f;

    //设置背景颜色

    label.backgroundColor = [UIColor redColor];

    //添加到父视图

    [self.view addSubview:label];

posted @ 2016-03-09 20:33  原码  阅读(170)  评论(0编辑  收藏  举报