Reputation: 183
I've been looking for a way to change the black background color during a flip horizontal animation, but so far, nothing did the trick for me.
This is what it looks like right now
I'd really appreciate it if anyone could help me! Here is the code that I've been using for the animation:
ViewController.h:
-(IBAction)howitworksbutton:(id)sender;
ViewController.m:
-(IBAction)howitworksbutton:(id)sender
{
howitworks *secondview = [[howitworks alloc] initWithNibName:nil bundle:nil];
secondview.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:secondview animated:YES];
}
I also created a new UIViewController subclass called 'howitworks'.
Regards, Ivar
Upvotes: 2
Views: 1445
Reputation: 7537
Swift 3:
open fileAppDelegate.swift
inside function didFinishLaunchingWithOptions
add window?.backgroundColor = hexStringToUIColor("#EEEEEE")
something more:
hexStringToUIColor
is a helper method, you can use your way to create UIColor
func hexStringToUIColor (_ hex:String) -> UIColor {
var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
if (cString.hasPrefix("#")) {
cString.remove(at: cString.startIndex)
}
if ((cString.characters.count) != 6) {
return UIColor.gray
}
var rgbValue:UInt32 = 0
Scanner(string: cString).scanHexInt32(&rgbValue)
return UIColor(
red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
alpha: CGFloat(1.0)
)
}
Upvotes: 0
Reputation: 28258
Try and set the background color of the window object of your app delegate:
YourAppDelegate *delegate =[[UIApplication sharedApplication] delegate];
[[delegate window] setBackgroundColor:[UIColor redColor]];
I believe this is the main background color that sits behind all of your application views.
Upvotes: 5