func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool
{
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
var root=RootViewController(nibName: nil, bundle: nil)
self.window!.rootViewController=root
self.window!.backgroundColor = UIColor.whiteColor()
self.window!.makeKeyAndVisible()
return true
}
RootViewController.swift中
// #pragma mark -- ViewControlle Life
override func viewDidLoad()
{
super.viewDidLoad()
self.view!.backgroundColor=UIColor.darkGrayColor()
var btn=UIButton.buttonWithType(UIButtonType.System) as UIButton
btn.frame=CGRectMake(120,150,80,80)
btn.setTitle("click me",forState:UIControlState.Normal)
btn.addTarget(self,action:"Clicked:",forControlEvents:UIControlEvents.TouchUpInside)
btn.setTitleColor(UIColor.greenColor(),forState:UIControlState.Normal)
self.view!.addSubview(btn)
}
// #pragm mark -- Action
func Clicked(sender:UIButton)
{
//直接这样创建有bug
// var alert=UIAlertView(title: "提示", message: "Clicked!", delegate: self, cancelButtonTitle: "确定")
// alert.show()
var alert = UIAlertView()
alert.title = "提示"
alert.delegate = nil
alert.addButtonWithTitle("确定")
alert.message = "Clicked!"
alert.show()
}
SwiftDemo
最新推荐文章于 2024-04-01 09:48:22 发布