Revealing Splash View is showing blank white screen after animation - ios

I am using this Github-Repo for a reavealing splash view.
I am calling it like this inside my AppDelegate:
let revealingSplashView = RevealingSplashView(iconImage: UIImage(named: "wIcon")!, iconInitialSize: CGSize(width: 120 * UIScreen.main.bounds.width / 414.0, height: 120 * UIScreen.main.bounds.width / 414.0), backgroundColor: .white)
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
revealingSplashView.startAnimation()
window?.rootViewController?.view.addSubview(revealingSplashView)
return true
}
I am facing an issue where sometimes after the animation is finished, it is not instantly transitioning to the other ViewController but showing a blank white screen.
Here is a screen-video for a better understanding.
Does anyone have an idea what can cause that?
Or is there an easy way to implement it without this repo?

You calling the revealingSplashView inside AppDelegate didFinishLaunchingWithOptions. If you check the documentation they clearly state to call it in the viewDidLoad method of your viewController. Your view has not been loaded that's why you got the delay.
Check the documentation which you linked above:
import RevealingSplashView
override func viewDidLoad() {
super.viewDidLoad()
//Initialize a revealing Splash with with the iconImage, the initial size and the background color
let revealingSplashView = RevealingSplashView(iconImage: UIImage(named: "twitterLogo")!,iconInitialSize: CGSize(width: 70, height: 70), backgroundColor: UIColor(red:0.11, green:0.56, blue:0.95, alpha:1.0))
//Adds the revealing splash view as a sub view
self.view.addSubview(revealingSplashView)

Related

Eureka Forms: How to change form global tint colour

I am using Eureka to implement a simple form in my project. The form seems to have blue tint in the tint bar buttons above the keyboard and I am unsure how to change it.
Is there a way to make the "Done" label green like the rest of my UI?
Updated Eureka 4.3.x
You should override a variable customNavigationAccessoryView in your controller
override var customNavigationAccessoryView: (UIView & NavigationAccessory)? {
// The width might not be correctly defined yet: (Normally you can use UIScreen.main.bounds)
let navView = NavigationAccessoryView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 44.0))
navView.barTintColor = UIColor.MaterialColors.category3
navView.tintColor = UIColor.white
return navView
}
Here you go and fix the colour of Done Label.
override NaviagtionAccessoryView Instance as navigationAccessoryView below
navigationAccessoryView.tintColor = "Your Colour"
navigationAccessoryView.backgroundColor = "Your Colour"
navigationAccessoryView.doneButton.tintColor = "Your Colour"
More Here
You can set a default tint color for all UIView instance by
UIView.appearance().tintColor = .red
appearance() is a method in UIAppearance protocol. UIView and its subclasses confirm to this protocol. You can also do
UIButton.appearance().tintColor = .green
Add the below line in AppDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
{
self.window?.tintColor = UIColor.black // You can set it to which color you want.
return true
}
All the tint color of the whole app will be changed to the given color.
This works for me perfectly:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
NavigationAccessoryView.appearance().tintColor = /* your color here */
}

Add a box around the selected tab bar item

I would like to do something in the vein of having a box appear or a circle around the tab bar item that the user has selected other than just changing the color. Is this even possible and if so how? Thanks in advance.
There are various ways to achieve this. I will list down 3 of them below.
1) You can set selectionIndicatorImage like this in AppDelegate,
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UITabBar.appearance().selectionIndicatorImage = #imageLiteral(resourceName: "boxImage")
return true
}
For the rest of 2 you have to create a subclass of UITabBarController like below and set this class in the storyboard for the tabBarController
class MyTabBarViewController: UITabBarController {
}
2) In this method you have to ask your designer to create the selected images with box. Set the unselected/normal and selected images like below in viewDidAppear and you are done.
3) Add an imageView in tabBar like below. In storyboard, you can assign tag for each tabBar item so that in the didSelect item callback, we will consider the tag as index of the selected item. Lets consider you have 5 tabBar items and you assigned tags from 0 to 4. Now you will just get the tag and update the position as shown below
class MyTabBarViewController: UITabBarController {
// MARK: - Properties
let imageView = UIImageView(image: #imageLiteral(resourceName: "boxImage"))
// MARK: View's Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
self.tabBar.addSubview(imageView)
}
/// Tabbar item selection callback
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
updateImagePosition(at: item.tag + 1)
}
private func updateImagePosition(at index: Int) {
guard let count = tabBar.items?.count else { return }
let eachItemWidth = view.bounds.width/CGFloat(count)
let selectedItemX = (eachItemWidth * CGFloat(index)) - eachItemWidth/2 - imageView.frame.width/2
let selectedItemY = tabBar.bounds.height/2 - imageView.frame.height/2
imageView.frame.origin = CGPoint(x: selectedItemX, y: selectedItemY)
}
}

StatusBarFrame in iOS 11

getting the statusBarFrame doesn't appear to return the correct value in iOS 11. I realize there may be a nicer way of dealing with this in the future using the Safe Area but right now I really need to get the statusBarFrame to work as it did before iOS 11. Here's how I usually get it.
UIApplication.shared.statusBarFrame
I'v verified that my app works properly before iOS 11. But in iOS 11 it appears to be backwards; for example, for an iPhone in portrait it should 20 and in landscape 0. But it returns 0 in portrait and 20 in landscape.
I've read all the posts regarding status bar issues and none address this problem.
I think it appears to be a timing issue. I wrapped the code that uses the statusBarFrame in a DispatchQueue.main.async {} closure and it works fine. I would consider this more of a bandaid. Still hoping for a proper solution.
Suggestions appreciated.
Thanks!
You can set background color for status bar during application launch or during viewDidLoad of your view controller. Here it works for me, in following ways.
extension UIApplication {
var statusBarView: UIView? {
return value(forKey: "statusBar") as? UIView
}
}
// Set upon application launch, if you've application based status bar
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.statusBarView?.backgroundColor = UIColor.red
return true
}
}
or
// Set it from your view controller if you've view controller based statusbar
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
UIApplication.shared.statusBarView?.backgroundColor = UIColor.red
}
}
Here is result:

iOS - Floating Single Button

I need a floating button in my iPhone app, I saw many libraries online like this one: https://cocoapods.org/pods/LiquidFloatingActionButton
But I need it to be just a single button, not a menu - Do you know of any other libraries that do this? Or a way to customise one of the current libraries to do what I need?
Thanks!
import UIKit
final class AppDelegate: NSObject, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
let buttonDiameter: CGFloat = 44.0
let floatingButton = UIButton(frame: CGRect(x: 0.0, y: 0.0, width: buttonDiameter, height: buttonDiameter))
floatingButton.layer.cornerRadius = buttonDiameter / 2.0
floatingButton.backgroundColor = .redColor()
window?.addSubview(floatingButton)
return true
}
}
This example would add a floating button to the top left corner of your app.
The important aspect of this code is that I am adding the button the UIWindow.
You can access the window of the app from any UIViewController whose view is added to the window via the property window.
To get notifications when a view controller is added to the window you can override the function:
didMoveToWindow()
There is an approach to this by using KCFloating action button and adding a tapGestureRecognizer to a view containing this button.
So, just adding KCFloatingActionButton's pod and adding another view containing it it's possible to have a single floating action button just as androids.
If you require more detail to solve this issue tell me and I'll try to help
Sample image
only copy and paste this code
override func viewDidAppear(_ animated: Bool) {
layoutFAB()
}
func layoutFAB() {
let item = KCFloatingActionButton()
item.buttonColor = UIColor(red: 188/255, green: 46/255, blue: 35/255, alpha: 1)
}
override func viewDidLoad() {
super.viewDidLoad()
let Fab = KCFloatingActionButton()
Fab.addItem("a", icon: UIImage(named: "a")){ item in
print("a")
}
}
self.view.addSubview(Fab)
}

Different Status Bar colour for iOS

I'm starting Developing for iOS and I want to know if someone knows how to change the status bar color like Youtube or Hangout apps do. I think that is overlaying a view but I do not know how to do it.
Thanks for all :).
Example 1: Hangout.
Example 2: Youtube.
Yes you'll need an overlay, it's how I would do to have an effect like in your examples:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let view: UIView = UIView.init(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.size.width, 20))
// We will apply a transparent black color to darken the status bar
view.backgroundColor = UIColor.blackColor()
view.alpha = 0.1
self.window!.rootViewController!.view.addSubview(view)
return true
}

Resources