美文网首页
改变Button的形状

改变Button的形状

作者: Dove_Q | 来源:发表于2016-08-21 19:36 被阅读432次
            let btn = UIButton(type: .System)
            btn.frame =  CGRect(x: 100, y: 100, width: 100, height: 100)
            btn.backgroundColor = UIColor.redColor()
            self.view.addSubview(btn)
            
            //CoreAnimation
            //UIView拥有一个CALayer,控制显示功能
            //圆角半径
            btn.layer.cornerRadius = 50
            //边框颜色
            btn.layer.borderColor = UIColor.yellowColor().CGColor
            //边框宽度
            btn.layer.borderWidth = 2
            //设置阴影颜色
            btn.layer.shadowColor = UIColor.blackColor().CGColor
            //阴影的透明度默认是0, 看不见
            btn.layer.shadowOpacity = 1
            //width: 相对于原图形向右平移, 否者相反
            //height: 相对于原图形向下平移, 否者相反
            btn.layer.shadowOffset = CGSize(width: 10, height: 20)
            //阴影半径
            btn.layer.shadowRadius = 20
    

    相关文章

      网友评论

          本文标题:改变Button的形状

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