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

stroke width an color change dynamically #58

Open
ouberghouz opened this issue Sep 25, 2021 · 1 comment
Open

stroke width an color change dynamically #58

ouberghouz opened this issue Sep 25, 2021 · 1 comment

Comments

@ouberghouz
Copy link

can you please add a way to to change the color and the width of the signature dynamically for the same signature.

@vladRGaembla
Copy link

@ouberghouz I found a solution. Here is an explanation how "userInterfaceStyle" works and how to prevent it
https://stackoverflow.com/questions/58501913/get-image-of-pkdrawing-in-light-mode

As a solution, you can try this

import PencilKit

extension PKDrawing {
  func image(from rect: CGRect, scale: CGFloat, userInterfaceStyle: UIUserInterfaceStyle) -> UIImage {
    let currentTraits = UITraitCollection.current
    UITraitCollection.current = UITraitCollection(userInterfaceStyle: .light) // Here the magic. Try .dark or .light
    let image = self.image(from: rect, scale: scale)
    UITraitCollection.current = currentTraits
    return image
  }
}

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

2 participants