美文网首页
圆形的UIView或者UIButton

圆形的UIView或者UIButton

作者: 哎呦我去叫什么呢 | 来源:发表于2016-03-23 14:14 被阅读1280次

    //先定义一个UIView

    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 50, 50)];

    //圆的半径是view宽的一半

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

    //是否进行剪切

    view.clipsToBounds = YES;

    //  给view一个颜色

    view.backgroundColor = [UIColor redColor];

    //添加到视图上

    [self.View addSubview:view];

    //UIButton

    UIButton * = [UIButton buttonWithType:(UIButtonTypeRoundedRect)];

    button.frame =CGRectMake(10, 10, 50, 50);

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

    button.clipsToBounds = YES;

    [self.view addSubview:button];

    相关文章

      网友评论

          本文标题:圆形的UIView或者UIButton

          本文链接:https://www.haomeiwen.com/subject/yeenkttx.html