//
// ViewController.swift
// NavigationController
//
import UIKit
import Foundation
class ViewController: UIViewController,FontSizeChangDelegate {
var myLabel :UILabel?;//声明一个UILabel对象 全局的
override func viewDidLoad() {
super.viewDidLoad()
//self.title = "百度";
self.navigationItem.title = "百度";
let nextItem = UIBarButtonItem(title: "下一页", style: .Plain, target: self, action: "nextPage");
self.navigationItem.rightBarButtonItem = nextItem;
//放一个Label可以显示文字
let rect = CGRect(x: 0, y: 100, width: 320, height: 44);
myLabel = UILabel(frame: rect);
myLabel!.text = "欢迎来到百度";
self.view.addSubview(myLabel!);
// Do any additional setup after loading the view, typically from a nib.
}
func nextPage(){
NSLog("按钮被点击了");
let svc = SubViewController();
//设置这个协定
svc.delegate = self;
self.navigationController?.pushViewController(svc, animated: true);
}
// 代理办法
func fontSizeDidChange(controller: SubViewController, fontSize: Int) {
println("controller is\(controller) fontsize:\(fontSize)");
let font = UIFont.systemFontOfSize(Float(fontSize));//这里有毛病
myLabel!.font = font;
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
//
// ViewController.swift
// NavigationControll