Prevent UINavigationBar in Share Extension from inheriting main application appearance settings

Prevent UINavigationBar in Share Extension from inheriting main application appearance settings

I created a share extension for my for which I had to create my own UI in the Storyboard. The entire thing works great except for the fact that the navigation bar inherits the main app's appearance. As examples:
Here it is in the NYT app:
 
Here it is in the Vice app:

How can I set my own appearance? 

Solutions/Answers:

Answer 1:

The share extension is intended to inherit from the main app’s preferred style. Your two examples show that, and I can’t recall an app that has a share extension that’s styled differently.

This question includes a thorough effort to fix this problem, including links to a rdar that’s filed with Apple.

Not the answer you want, but there doesn’t appear to be a “non-hacky” way of achieving this.

Answer 2:

What I would do is subclass UINavigationBar as MYNavigationBar, and then apply my custom appearance styles to MYNavigationBar.

I’d then use MYNavigationBar instead of UINavigationBar (just change the class type in the storyboard) throughout the app.

Answer 3:

It simply cannot be done with existing APIs, as is pointed out by other answers. I tried subclassing UINavigationBar and even overriding things like tintColor and backgroundColor, but that didn’t work either.

What I ended up doing in the end is using a view and style it to look like a navigation bar, it works well. It’s a little bit hacky, but it’s still ok since it will most likely never break with future releases of iOS…

Answer 4:

I found a way!

Just draw an Image with your color!

func getTopWithColor(color: UIColor, size: CGSize) -> UIImage {
    let rect = CGRect(x: 0,y:  0,width: size.width,height: size.height)
    UIGraphicsBeginImageContextWithOptions(size, false, 0)
    color.setFill()
    UIRectFill(rect)
    //if let img = UIImage(named: "test.jpg") {
        //img.draw(in: CGRect(x: 0,y: 0,width: size.width,height: size.height))
    //    img.draw(in: CGRect(x: 0,y: 0,width: size.width,height: size.height), blendMode: .darken, alpha: 0.5)
    //}
    let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()!

    UIGraphicsEndImageContext()
    return image
}

.

override func viewDidLoad() {

let c = UIColor(red: 0.5765, green: 0.2784, blue: 0, alpha: 0.5)
    //c.withAlphaComponent(CGFloat(0))
    self.navigationController?.navigationBar.tintColor = UIColor.black
    let navSize = self.navigationController?.navigationBar.frame.size
    let image1 = getTopWithColor(color: c, size: navSize!)

    self.navigationController?.navigationBar.setBackgroundImage(image1, for: .default)

Our Awesome Free Tools

References

Unable To debug with AppCode after upgrading to Xcode 7.3

Unable To debug with AppCode after upgrading to Xcode 7.3

After I updated Xcode to 7.3 I am unable to start debugging with AppCode 3.3.2 & 3.3.3 I am just able to Run without debugging each time I start debbuging with appcode this happens in the console:
/Users/labib/Library/Caches/AppCode33/DerivedData/TestApp-e195af2c/Build/Products/Debug-iphonesimulator/TestApp.app
Stopping simulator session...
Simulator session started with process 3047
Process finished with exit code 0

Solutions/Answers:

Answer 1:

JetBrains is aware of this issue and have a fix as part of the current RC (see their latest AppCode blog post).

Their current advice is essentially to download the RC version from their AppCode EAP page if you’ve already upgraded to XCode 7.3. NOTE: It does require a license or you can use a 30 day eval period.

Our Awesome Free Tools

References