Делаем светлый статус-бар на Swift2 в iOS 9 Xcode 7
Если в вашем приложении темный фон, то к нему идеально подойдет белый статус бар ) Ниже всего одна строчка кода которая изменит все. UINavigationBar.appearance().barStyle = .Black Для того, чтобы она заработала в Navigation Bar Controller и на всех экранах вас радовал белый цвет статус бара добавьте ее в файл AppDelegate.Swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Сделаем светлый статус бар UINavigationBar.appearance().barStyle = .Black }
Вот так и делаем светлый статус-бар на Swift2 в iOS 9 Xcode 7
Как скрыть бар в Navigation View controller на одном из ViewController?
Эта неделя богата на небольшие, но полезные туториалы. Полезно иметь под рукой некую библиотеку часто-используемых функций, чтобы не переписывать по несколько раз типовые операции. Итак, сегодня рассмотрим туториал "Как скрыть бар в Navigation View controller на одном из ViewController?" Странное и непонятное название? В общем суть такая, есть navigation view controller который идет по всем экранам, для которых добавлены переходы, но есть некий главный экран, на котором мы не хотим видеть навигационного бара. Для наглядности вот вам картинка как было и то что хотим сделать. [caption id="attachment_75" align="aligncenter" width="585"] navigation view controller swift 2.0[/caption] [caption id="attachment_74" align="aligncenter" width="585"] navigation view controller swift 2.0 target[/caption] Как видите на втором экране у нас не виден навигационный бар. Конечно в storyboard вы его будете видеть, но как только запустите приложение он будет скрыт. Поэтому эта картинка дана лишь для наглядности состояний. В сториборде конечно же можно задать скрытие бара по тапу или свайпу, но мы применим программистский подход и в этом шорт туториале покажу как проще всего скрыть NavigationViewController Bar. Для этого достаточно на целевом файле с ViewController задать функцию
// Скроем навигационный бар override func viewWillDisappear(animated: Bool) { super.viewWillDisappear(animated) // вот тут как раз и скрываем навигационный бар self.navigationController?.navigationBarHidden = false }
Вообще полезно заглянуть в help по этой функции и посмотреть какие могут быть варианты отображения
func viewWillAppear(animated: Bool) // Called when the view is about to made visible. Default does nothing func viewDidAppear(animated: Bool) // Called when the view has been fully transitioned onto the screen. Default does nothing func viewWillDisappear(animated: Bool) // Called when the view is dismissed, covered or otherwise hidden. Default does nothing func viewDidDisappear(animated: Bool) // Called after the view was dismissed, covered or otherwise hidden. Default does nothing
Все, запускайте проект и любуйтесь, navigation controller будет убран.
Делаем светлый статус-бар на Swift2 в iOS 9 Xcode 7
Если в вашем приложении темный фон, то к нему идеально подойдет белый статус бар ) Ниже всего одна строчка кода которая изменит все. UINavigationBar.appearance().barStyle = .Black Для того, чтобы она заработала в Navigation Bar Controller и на всех экранах вас радовал белый цвет статус бара добавьте ее в файл AppDelegate.Swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Сделаем светлый статус бар UINavigationBar.appearance().barStyle = .Black }
Вот так и делаем светлый статус-бар на Swift2 в iOS 9 Xcode 7
Как скрыть бар в Navigation View controller на одном из ViewController?
Эта неделя богата на небольшие, но полезные туториалы. Полезно иметь под рукой некую библиотеку часто-используемых функций, чтобы не переписывать по несколько раз типовые операции. Итак, сегодня рассмотрим туториал "Как скрыть бар в Navigation View controller на одном из ViewController?" Странное и непонятное название? В общем суть такая, есть navigation view controller который идет по всем экранам, для которых добавлены переходы, но есть некий главный экран, на котором мы не хотим видеть навигационного бара. Для наглядности вот вам картинка как было и то что хотим сделать. [caption id="attachment_75" align="aligncenter" width="585"] navigation view controller swift 2.0[/caption] [caption id="attachment_74" align="aligncenter" width="585"] navigation view controller swift 2.0 target[/caption] Как видите на втором экране у нас не виден навигационный бар. Конечно в storyboard вы его будете видеть, но как только запустите приложение он будет скрыт. Поэтому эта картинка дана лишь для наглядности состояний. В сториборде конечно же можно задать скрытие бара по тапу или свайпу, но мы применим программистский подход и в этом шорт туториале покажу как проще всего скрыть NavigationViewController Bar. Для этого достаточно на целевом файле с ViewController задать функцию
// Скроем навигационный бар override func viewWillDisappear(animated: Bool) { super.viewWillDisappear(animated) // вот тут как раз и скрываем навигационный бар self.navigationController?.navigationBarHidden = false }
Вообще полезно заглянуть в help по этой функции и посмотреть какие могут быть варианты отображения
func viewWillAppear(animated: Bool) // Called when the view is about to made visible. Default does nothing func viewDidAppear(animated: Bool) // Called when the view has been fully transitioned onto the screen. Default does nothing func viewWillDisappear(animated: Bool) // Called when the view is dismissed, covered or otherwise hidden. Default does nothing func viewDidDisappear(animated: Bool) // Called after the view was dismissed, covered or otherwise hidden. Default does nothing
Все, запускайте проект и любуйтесь, navigation controller будет убран.
Disable back swipe gesture in UINavigationController
From iOS 7 there is a new navigation behavior.
You can swipe from left border of the screen to go back on navigation stack.
How can you disable this behavior? Get the solution below (replace self.navigationController with self when you are in the UINavigationController class)
So, today's topic will be touching about something new in iOS8. But before that, I am very excited about today's post, I finally posted a video!! I know it can be easily done in Tumblr, but, it's my first ever video on Tumblr. Cheers to that!
Not sure if you notice this, but if you try scrolling in your Safari mobile app, you'll notice that the navigation bar gets "compressed". We aren't exactly going to do that, but something close enough. Ever wished to make your app to have the fullscreen experience? Now in iOS8, you can easily do that with a bunch of properties.
TODAY's TOPIC : HIDING NAVIGATION BAR IN IOS8
In the video, I've shown you two ways to hide the navigation bar. First was hiding it by just a tap on the screen. The second way, which would probably be more useful, was hiding the navigation bar when keyboard appears.
How to do it??
In iOS8, there's a couple of properties that allows us to hide the navigation bar. Here is the super simple and short code that I've used to demonstrate both the effects as seen in the video:
Custom Segue and Custom Unwind Segue with Animations using Navigation Controller - Part 2/2
IOS 8.1 Xcode 6.1 tutorial: Customize Segue and UnwindSegue
Our goal this animation between the 2 ViewController:
6 Step need:
1. Create Custom Segue class and “-(void)perform” code
2. Change the Segue class on the storyboard
3. Test your Custom Segue in IOS Simulator
4. Create UnwindSegue
5. Detect MyCustomUnwindSegue on Storyboard
6. Test your CustomUnwindSegue and add color to your window background
Check the video, which just 6 minute! :)
If you are beginner, check the 1 part!
1. Create Custom Segue class and “-(void)perform” code
1.1. Right click New File — Cocoa Touch Class - name: MyCustomSegue, type: UIStoryboardSegue
1.2. in MyCustomSegue.m file create “-(void)perform” code:
You can refer to source VieController and destination ViewController, simply, and you can use the MyCustomSegue several places on the storyboard, regardless of which specific ViewController use it.
1.3. Put the animation into the -(void)perform code:
For example just come the destination ViewController from up to down, and source ViewController just goes down. So the full perform code looks like this:
2. Change the Segue class on the storyboard
2.1. Click on the segue, and in the Attributes inspector change the Segue from “Show” to “Custom”.
4.1. Repeat the first Step, so add New File with MyCustomUnwindSegue name…
4.2. …and copy perform code but change the y coordinates in the UIViewAnimation to move up your destination ViewController and source too.
Attention! - Changes:
4.3. the easiest way is to copy the code from here. :)
4.4.In ViewController.m file create the IBAction UIStoryboardSegue to handle the custom unwind segue, and add if statement to change the background to orangeColor:
Now you have 2 type of UnwindSegue in your code. The first is the normal UnwindSegue, and the second your own CustomUnwindSegue. So if you use CustomUnwindSegue, and would like to do some changes after segue animation, you can code here in returnedFromSegue
Your code looks like this:
4.5. Add returnedFromSegue to your new UnwindSegue at your SecondViewController’s button.
- ctrl drag to Exit, and choose returnedFromSegue
- click on the UnwindSegue, and add UnwindFromSecondView as Identifier.
5. Detect MyCustomUnwindSegue on Storyboard
5.1. Do in ViewController.m : import MyCustomUnwindSegue.h file
5.2. If you not use NavigationController just put this segueForUnwindingToViewController:code in ViewController.m, this will be detect which segue should be use MyCustomUnwindSegue class:
5.3. If you use NavigationController on your first ViewController (where comes the UnwindSegue), you should subclass your navcontroller:
5.3.1. Add New Cocoa Touch Class File, name: MyNavController, type: UINavigationController
5.3.2. On Storyboard add your new class to your NavigationController.
5.3.2. In MyNavController.m file import MyCustomUnwindSegue.h file, and put the segueForUnwindingToViewController:code. So your MyNavController file looks like this:
6. Test your CustomUnwindSegue and add color to your window background
6.1. Play in IOS Simulator.
If you would like to some other color instead of black window background, just put this color code in MyCusotmUnwindSegue.m file
window.backgroundColor = [UIColor redColor];
looks like this:
6.2. And test again with red window background color:
Download code
You can download the whole tutorial from github:MyCustomSegue.git
If you would like to be notified of my new solutions, please subscribe to my youtube channel and/ or follow me on twitter!