IOS Swift3.0 UiView Demo1
来源:互联网 发布:做假章软件 编辑:程序博客网 时间:2024/05/03 16:51
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let viewRect = CGRect(x: 50, y: 50, width: 100, height: 100)
let view1 = MyView(frame: viewRect)
self.view.addSubview(view1)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
class MyView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
//把背景色设为透明
self.backgroundColor = UIColor.clear
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func draw(_ rect: CGRect) {
let pathRect = self.bounds.insetBy(dx: 1, dy: 1)
let path = UIBezierPath(roundedRect: pathRect, cornerRadius: 10)
path.lineWidth = 3
UIColor.green.setFill()
UIColor.blue.setStroke()
path.fill()
path.stroke()
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let viewRect = CGRect(x: 50, y: 50, width: 100, height: 100)
let view1 = MyView(frame: viewRect)
self.view.addSubview(view1)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
class MyView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
//把背景色设为透明
self.backgroundColor = UIColor.clear
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func draw(_ rect: CGRect) {
let pathRect = self.bounds.insetBy(dx: 1, dy: 1)
let path = UIBezierPath(roundedRect: pathRect, cornerRadius: 10)
path.lineWidth = 3
UIColor.green.setFill()
UIColor.blue.setStroke()
path.fill()
path.stroke()
}
}
阅读全文
0 0
- IOS Swift3.0 UiView Demo1
- iOS Swift3.0 UIView动画详解
- IOS GCD Swift3.0
- Swift3之UIView
- iOS开发 Swift3.0 Error
- IOS-DEMO1 PLLSlideToUnlock
- [iOS Swift3.0 ]Guard语句理解 [转载]
- [iOS Swift3.0语法变化] 方便查询
- iOS启动页广告swift3.0
- IOS Swift3.0自定义导航栏(UINavigation)
- iOS实现iCloud数据存储-Swift3.0
- iOS swift3.0 下闭包语法整理
- 【Mac/ios】Swift3.0 BLE开发
- IOS Swift3.0 URLSessionTask get/post
- IOS Swift3.0 URLSession和Json解析
- iOS/Swift3.0 终端命令自动打包
- IOS 星星评分控件-Swift3.0
- ios swift3.0监听网络状态
- 优化下面的程序
- Kali 2 Kali 2017更新源
- 用Boost库中的cpu_timer计算caffe测试时间
- LeetCode 49 Group Anagrams
- 提取不重复的整数
- IOS Swift3.0 UiView Demo1
- 导游
- 程序员面试金典——阶乘尾零
- linux如何卸载自带的openJdk,并且安装jdk1.8
- hihocoder 1290 面试题(dp)
- POJ2566 Bound Found
- 使用适当的智能指针优化下面的程序
- javaScript对象
- 十分钟理解Java中的动态代理----强烈推荐