//
// ViewController.swift
// TestApp1
//
// Created by Divakar Singh on 3/1/17.
// Copyright (c) 2017 Divakar Singh. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
var label1 : UILabel!
var sl1 : UISlider!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// create label
label1 = UILabel()
label1.frame = CGRect(x: 50, y: 100, width: 300, height: 36)
label1.text = "Default Value"
view.addSubview(label1)
// create switch
sl1 = UISlider()
sl1.sizeToFit()
sl1.center = CGPoint(x: 100, y: 150)
sl1.minimumValue = 10.0
sl1.maximumValue = 60.0
sl1.value = 25
sl1.addTarget(self, action: "valueChangeM:", forControlEvents: UIControlEvents.ValueChanged)
view.addSubview(sl1)
}
func valueChangeM(sender : UISlider)
{
label1.text = "Value is : \(sender.value)"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
No comments:
Post a Comment