-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
exposes icon fontweight from SF Symbol #43
base: master
Are you sure you want to change the base?
exposes icon fontweight from SF Symbol #43
Conversation
@@ -21,10 +21,19 @@ enum AlertPreset: String, Enumerable { | |||
case .spinner: | |||
return .spinner | |||
case .custom: | |||
guard let image = UIImage.init( systemName: options?.icon?.name ?? "swift") else { | |||
throw BurntError.invalidSystemName | |||
let weight: UIImage.SymbolWeight |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about:
let weight = try? toFontWeight(from: options?.icon?.fontWeight) ?? .regular
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think i tried something like this earlier, but tried it again and got something like this:
let configuration = UIImage.SymbolConfiguration(weight: weight)
... value of optional type 'UIImage.SymbolWeight?' must be unwrapped to a value of type 'UIImage.SymbolWeight'
that being said, this worked. wdyt?
guard let weight = try? toFontWeight(from: options?.icon?.fontWeight) else {
throw BurntError.invalidIconWeight
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you try the exact code i gave? mine has a fallback to regular
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that being said, this worked. wdyt?
that code doesn't not work because it will throw if weight isn't given, but it's optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i ran the exact code, here's what the whole custom block looks like:
case .custom:
let weight = try? toFontWeight(from: options?.icon?.fontWeight) ?? .regular
let configuration = UIImage.SymbolConfiguration(weight: weight)
guard let image = UIImage(systemName: options?.icon?.name ?? "swift", withConfiguration: configuration) else {
throw BurntError.invalidSystemName
}
return .custom(image.withTintColor(options?.icon?.color ?? .systemBlue, renderingMode: .alwaysOriginal))
with the same error (i just tried again)
Exposes
fontWeight
bold checkmark:
black checkmark:
ultralight checkmark: