-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Added new extensions #1097
Added new extensions #1097
Conversation
- Parameter rgb: An unsigned 32 bit integer. E.g 0xAA44CC. | ||
*/ | ||
convenience init(rgb: UInt32) { | ||
self.init(argb: (UInt32(0xff000000)) | rgb) |
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.
@DanielDahan You might wonder why I didn't use Int
. As far as I remember, using it was causing crash on 32-bit devices. Even on iPhone 4s simulator for example. I can't verify since I don't have 32bit simulator and won't be able to get it soon. Can you please try it with Int
or UInt
. With UInt32
it works I am sure. But it will fail to compile with Int32
when a large interger value is used. e.g UIColor(argb: 0xFFFFFFFF)
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.
Interesting. Does The reason I believe UInt32
works over Int32
is because UInt32
is unsigned which means all values are positive and it could hold a larger range, where Int32
is signed and therefore holds a smaller positive range but both negative and positive. So please use UInt32
.
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.
Yeah sure, I know. I meant larger in terms of positivity. Thank you for explaining :)
Sources/iOS/Material+UIButton.swift
Outdated
public extension UIButton { | ||
/// Convenience way to change titleLabel font size. | ||
var fontSize: CGFloat { | ||
set { |
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.
For the setter and getter, please you use this format:
get {
return ...
}
set(value) {
... = value
}
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 have to use value
or I can use for example size
?
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.
Does set get order matter?
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.
Both order and name matter. As it is consistent with the entire framework. Also, helps to search everything easily when it is the same naming and format.
Thank you! |
Added
UIColor(argb:)
,UIColor(rgb:)
,UIButton.fontSize
,UILabel.fontSize