//
// 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 tool1 : UIToolbar!
var label1 : UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// create toolbar
tool1 = UIToolbar()
tool1.sizeToFit()
tool1.backgroundColor = UIColor.redColor()
let flexBarButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: self, action: nil)
let doneButton = UIBarButtonItem(title: "Click Me", style: UIBarButtonItemStyle.Bordered, target: self, action: Selector("doneClicked"))
var items = [UIBarButtonItem]()
items.append(flexBarButton)
items.append(doneButton)
tool1.items = items
view.addSubview(tool1)
// create label
label1 = UILabel()
label1.frame = CGRect(x: 100, y: 100, width: 200, height: 36)
label1.text = "Default"
label1.backgroundColor = UIColor.grayColor()
view.addSubview(label1)
}
func doneClicked()
{
label1.text = "Changed Done"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
No comments:
Post a Comment