2023年7月14日发(作者:)
[Xcode实际操作]四、常⽤控件-(12)环形进度条控件的使⽤⽬录:本⽂将演⽰环形进度条控件的使⽤。在项⽬导航区,打开视图控制器的代码⽂件【】 1 import UIKit 2
3 class ViewController: UIViewController { 4
5 //⾸先添加⼀个环形进度条对象 6 var indicator:UIActivityIndicatorView! 7
8 override func viewDidLoad() { 9 dLoad()10 // Do any additional setup after loading the view, typically from a nib.11 //设置根视图的背景颜⾊为紫⾊12 oundColor = 13
14 //初始化环形进度条,并设置环形进度条的样式为⼤⽩15 indicator = UIActivityIndicatorView(style: arge)16 //设置环形进度条中⼼点的位置为(160,120)17 = CGPoint(x: 160, y: 120)18 //开始进度条动画的播放19 nimating()20
21 //将环形进度条,添加到当前视图控制器的根视图22 view(indicator)23
24 //创建⼀个位置在(20,200),尺⼨为(280,44)的按钮对象25 let button = UIButton(frame: CGRect(x: 20, y: 200, width: 280, height: 44))26 //然后设置按钮的标题⽂字27 le("Stop", for: .normal)28 //设置按钮的背景颜⾊为橙⾊29 oundColor = 30 //接着给按钮对象,绑定点击事件31 get(self, action: #selector(imation(_:)), for: pInside)32
33 //将按钮对象,添加到视图控制器的根视图34 view(button)35 }36
37 //创建⼀个⽅法,⽤来响应按钮的点击事件38 @objc func stopAnimation(_ button:UIButton)39 {40 //当点击按钮时,41 //停⽌环形进度条的动画播放42 imating()43 }44
45 override func didReceiveMemoryWarning() {46 eiveMemoryWarning()47 // Dispose of any resources that can be recreated.48 }49 }
发布者:admin,转转请注明出处:http://www.yc00.com/web/1689265701a226478.html
评论列表(0条)