在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
// ViewController.swift // Layer // // Created by hong wang on 2017/6/2. // Copyright © 2017年 appio. All rights reserved. // import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. //Layer Deomo 使用Button let btn:UIButton = UIButton(type: .system) btn.frame = CGRect(x: 10, y: 50, width: 70, height: 30) btn.setTitle("按钮", for: .normal) btn.setTitleColor(UIColor.blue, for: .normal) btn.backgroundColor = UIColor.white //设置圆边 //btn.layer.masksToBounds = true btn.layer.cornerRadius = 6 //设置边框 btn.layer.borderWidth = 2 btn.layer.borderColor = UIColor.blue.cgColor //设置阴影 btn.layer.shadowColor = UIColor.purple.cgColor btn.layer.shadowOffset = CGSize(width: 2, height: 2) btn.layer.shadowOpacity = 0.4 self.view.addSubview( btn ) btn.addTarget(self, action: #selector(ViewController.btnClick), for: UIControlEvents.touchUpInside) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } print( "Btn Clicked!") } } |
请发表评论