var button = UIButton(frame: CGRect(x:0,y:0,width:100,height:100))
button.setTitle("你好",forControlEvents:.Normal)
button.addTarget(self,action:"clickMe",forControlEvents:.TouchUpInside)
button.backgroundColor= UIColor.blueColor()
self.view.addSubview(button)
//2 UINavigation
let rcv :UIViewController = RootViewController()
//创建导航控制器
let nav = UINavigationController(rootViewController:rcv)
self.window!.rootViewController = nav;
RootViewController.Swift
import Foundation
import UIKit
class RootViewController: UIViewController,FontSizeChangeDelegate{
override func viewDidLoad()
{
self.title = "title"
//右边放一个按钮UIBarButtonItem
let nextItem = UIBarButtonItem(title:"下一页",style:.plain,
target:self,action:"nextPage")
self.navigationItem.rightBarButtonItem = nextItem
var b = UIButton.buttonWithType(.System) as UIButton
var frame = CGRect(x:100,y:100,width:100,height:40)
b.frame = frame
b.setTitle("返回上一层", forState:.Normal)
b.addTarge(self,action:"clickMe:",forControllerEvent:.TouchUpSide)
self.view.addSubview(b)