滑块
1. 创建
let Sli: UiSlider = UiSlider(frame: CGRectMake(10.0,270,300,5)) as UiSlider Sli.minimumValue = 10 Sli.maximumValue = 300 Sli.continuous = false
continous属性为true:滑块在滑动过程中响应事件,为false时则只在滑动后响应事件
2.设置各区域的图片
//滑块左边和右边的视图 Sli.setMinimumTrackImage(UIImage(named: "green.png"),forState: UIControlState.normal) Sli.setMinimumTrackImage(UIImage(named: "green.png"),forState: UIControlState.normal) //滑块的视图 //Sli.setThumbImage(UIImage(named: "green.png"),forState: UIControlState.normal) //滑块最大值和最小值处的图片 //Sli.minimumValueImage = UIImage(named: "green.png") //Sli.maximumValueImage = UIImage(named: "green.png")
3.响应事件和Tag
Sli.addTarget(self,action: "Progress",forControlEvents: UIControlEvents.ValueChanged) Sli.tag = 2
4. 获取滑块的值
let prog:UiSlider = self.vIEw.vIEwWithTag(2) as! UiSlider let a = prog.value
进度条
1创建
let Progress: UIProgressVIEw = UIProgressVIEw(frame: CGRectMake(10,3)) Progress.progress = 0.0 Progress.tag = 1
2.设置
let a = 50 aaa.setProgress(a/100,animated: false)
步进控件
1.创建
let stepPro: UIStepper = UIStepper(frame: CGRectMake(10,310,5)) stepPro.minimumValue = 0 stepPro.maximumValue = 100 stepPro.value = 0 stepPro.stepValue = 2.0
2.响应事件
stepPro.addTarget(self,action: "stepEven:",forControlEvents: UIControlEvents.touchDown) stepPro.continuous = true stepPro.tag = 255
continuous属性UiSlider类似
3.获取步进的值
let setp: UIStepper = self.vIEw.vIEwWithTag(255) as! UIStepper let a = setp.value NSLog("\(a)")总结
以上是内存溢出为你收集整理的swift爬行篇 滑块,进度条,步进,全部内容,希望文章能够帮你解决swift爬行篇 滑块,进度条,步进,所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)