Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to avoid dark mode? #50

Open
RonnyCoder opened this issue Nov 17, 2020 · 4 comments
Open

How to avoid dark mode? #50

RonnyCoder opened this issue Nov 17, 2020 · 4 comments

Comments

@RonnyCoder
Copy link

RonnyCoder commented Nov 17, 2020

I don't want to support dark mode to my App. Issue is at self.signatureView.getCroppedSignature() this return dark mode supported image with white stroke. Need to support only for light theme with black stroke.
I tried with setting stroke, background color, tint color but didn't work. Please provide solution.

Thanks in advance.

@RonnyCoder
Copy link
Author

RonnyCoder commented Nov 18, 2020

Solution:
Set self.window?.overrideUserInterfaceStyle = .light
Don't add UIUserInterfaceStyle at plist, possibly you may face app rejection.
For me setting overrideUserInterfaceStyle to viewcontroller/view not worked.

@bludginozzie
Copy link

Why does this signatureView.strokeColor = UIColor.blue work in dark mode but this signatureView.strokeColor = UIColor.black does not?

Like many others here I am trying to get a consistent signature image of black on white across both dark and light modes. Unfortunately after playing with it for several hours I do not think it's possible.

Any assistance would be greatly appreciated.

My full code which does not work, it results in a white stroke on a white background:

override func viewDidLoad() {
        super.viewDidLoad()
        
        let value = UIInterfaceOrientation.landscapeLeft.rawValue
        UIDevice.current.setValue(value, forKey: "orientation")
        
        // Force black stroke on white background so the signature image is consistent
        // for both light and dark modes
        signatureView.strokeColor = UIColor.black
        signatureView.backgroundColor = UIColor.white
        signatureView.minimumStrokeWidth = 1
        signatureView.maximumStrokeWidth = 1
        signatureView.strokeAlpha = 1
        if #available(iOS 13.0, *) {
            self.view.window?.overrideUserInterfaceStyle = .light
            if let signaturInnerView = signatureView.subviews.first(where: {$0 is PencilKitSignatureView}) as? PencilKitSignatureView {
                signaturInnerView.strokeColor = UIColor.black
                if let canvasView = signaturInnerView.subviews.first(where: {$0 is PKCanvasView}) {
                    canvasView.backgroundColor = UIColor.white
                }
            }
        }
    }

@sddanila
Copy link

Hey!
I solved this by always using black, but when it's dark theme, then set the alpha to 0.1.

So instead of using UIColor.white, I used UIColor.black.withAlphaComponent(0.1)

@vladRGaembla
Copy link

I found this solution. Hope it saves your day as saved mine:
#58 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants