码迷,mamicode.com
首页 > 移动开发 > 详细

IOS 今天学到太多的知识了,赶快记录下来

时间:2016-01-14 06:15:31      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:

TabBarController 修改tabbar的背景颜色和选中时候的颜色:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        
        application.registerUserNotificationSettings(UIUserNotificationSettings(
            forTypes:UIUserNotificationType.Badge, categories: nil))
        
        UIApplication.sharedApplication().cancelAllLocalNotifications()
        
        let localNotification = UILocalNotification()
        localNotification.applicationIconBadgeNumber = 78
        UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
        
        UITabBar.appearance().tintColor = UIColor(red: 227.0/255.0, green: 28.0/255.0, blue: 31.0/255.0, alpha: 1)
        UITabBar.appearance().barTintColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
        
        return true
    }

文章链接:http://www.uisdc.com/xcode-tutorials-for-designer-4

设置 Tabbaritem 上的图章

 

class myTabBarController: UITabBarController, UITabBarControllerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.delegate = self
        
        NSLog("Number of view controllers: \(self.viewControllers?.count)")
        
        self.viewControllers![0].tabBarItem.badgeValue = String(100)
        self.viewControllers![1].tabBarItem.badgeValue = "..."
        self.viewControllers![2].tabBarItem.badgeValue = "s"
        self.viewControllers![3].tabBarItem.badgeValue = "-"
        
        //self.viewControllers![0].tabBarItem.

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

 

手工建立一个TabbarController: http://www.cnblogs.com/wendingding/p/3775488.html

 

Swift - 设置应用程序图标的提醒个数(右上角小红圈)

使用UILocalNotification除了可以实现本地消息的推送功能(可以设置推送内容,推送时间,提示音),还可以设置应用程序右上角的提醒个数。
 
下面演示如何设置,效果图如下:
技术分享
 
--- AppDelegate.swift ---
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import UIKit
 
@UIApplicationMain
class AppDelegateUIResponderUIApplicationDelegate {
 
    var window: UIWindow?
 
    func application(application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [NSObjectAnyObject]?) -> Bool {
        application.registerUserNotificationSettings(UIUserNotificationSettings(
            forTypes: UIUserNotificationType.Sound UIUserNotificationType.Alert |
            UIUserNotificationType.Badge, categories: nil))
        return true
    }
 
    func applicationWillResignActive(application: UIApplication) {
    }
 
    func applicationDidEnterBackground(application: UIApplication) {
    }
 
    func applicationWillEnterForeground(application: UIApplication) {
    }
 
    func applicationDidBecomeActive(application: UIApplication) {
    }
 
    func applicationWillTerminate(application: UIApplication) {
    }
}

--- ViewController.swift ---
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import UIKit
 
class ViewControllerUIViewController {
     
    override func viewDidLoad() {
        super.viewDidLoad()
         
        //发送通知消息
        scheduleNotification();
    }
     
    //发送通知消息
    func scheduleNotification(){
        //清除所有本地推送
        UIApplication.sharedApplication().cancelAllLocalNotifications()
         
        //创建UILocalNotification来进行本地消息通知
        var localNotification = UILocalNotification()
        //设置应用程序右上角的提醒个数
        localNotification.applicationIconBadgeNumber = 78;
        UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
    }
     
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}


原文出自:www.hangge.com  转载请保留原文链接:http://www.hangge.com/blog/cache/detail_796.html

IOS 今天学到太多的知识了,赶快记录下来

标签:

原文地址:http://www.cnblogs.com/zengsiyu/p/5128989.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!