UISlider

//

//  SliderViewController.swift

//  UIControlDemo

//

//  Created by   on 14/12/4.

//  Copyright (c) 2014 马大哈. All rights reserved.

//

 

import UIKit

 

class SliderViewController: BaseViewController {

 

    

    var slider: UISlider?

    

    override func viewDidLoad() {

        super.viewDidLoad()

        

        slider = UISlider(frame: CGRectMake(20, 400, self.view.frame.size.width-40, 50))

        slider?.minimumValue = 1

        slider?.maximumValue = 100

        slider?.addTarget(self, action: "valueChanged:", forControlEvents: UIControlEvents.ValueChanged)

        self.view.addSubview(slider!)

        

    }

    

    

    

    func valueChanged(sender:UISlider){

    

        let value = "\(Int(sender.value))"

           self.title = value

 

    }

    

 

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

        // Dispose of any resources that can be recreated.

    }

   

}

 

 

posted on 2014-12-04 20:07  马大哈哈  阅读(89)  评论(0编辑  收藏  举报

导航