标签:getview wan set creat nat moved height obj red
//
// ViewController.swift
// Label
//
// Created by 赵士军 on 2019/11/18.
// Copyright © 2019 赵士军. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// Swift UIView
/*
UIResponder: 可以让继承他的类响应移动设备的触碰事件,由于可能存在多个响应所以iOS会将事件沿着响应链向上传递
UIView:是所有控件的父类,控件用于响应用户的交互,而UIView负责布局和显示 (UIResponder + UILayer + Animation )
UIWindow:提供了一个用于管理和显示视图的窗口。窗口提供了其他所有视图的根容器,每一个APP只有一个窗口
UIControl:几乎是所有交互事件的父类 ,AS: 按钮 滑块 文本框等 SO:UIControl负责根据触碰事件触发响应的动作
*/
//添加View
self .getView()
}
@objc func getView(){
let testView = UIView.init()
testView.backgroundColor = .green
testView .alpha=0.6
testView .isHidden = false
testView.frame=CGRect(x: 0, y: 0, width: 100, height: 100)
testView.center=self.view.center
testView.layer.cornerRadius=50
testView.layer.borderWidth=10
testView.layer.borderColor = UIColor.red.cgColor
self.view .addSubview(testView)
}
// override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
//
// }
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
do {
}
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
标签:getview wan set creat nat moved height obj red
原文地址:https://www.cnblogs.com/ZsjXxy/p/11883520.html