UIApplication常用设置

//
//  ViewController.swift
//  ios程序启动
//
//  Created by zhang on 16/1/16.
//  Copyright © 2016年 jin. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        super.touchesBegan(touches, withEvent: event)
        let app = UIApplication.sharedApplication()
        //设置联网状态
        app.networkActivityIndicatorVisible = app.networkActivityIndicatorVisible ? false : true
        //设置图标消息数字,需要先获得权限
        let userSeting = UIUserNotificationSettings(forTypes: UIUserNotificationType.Badge, categories: nil)
        app.registerUserNotificationSettings(userSeting)
        //再设置数字
        app.applicationIconBadgeNumber = 10
        //打开网址
        app.openURL(NSURL(string: "http://baidu.com")!)
    }

}

标签: swift, ios控件

添加新评论