Reputation: 3581
When I try to use UIButtonType
in swift, UIButtonTypeRoundedRect no longer exists:
Is there an equivalent in Swift, or do I need to make a new subclass to get the same look?
Upvotes: 2
Views: 487
Reputation: 21249
It's not in SDK included within Xcode 6.4:
enum UIButtonType : Int {
case Custom // no button type
@availability(iOS, introduced=7.0)
case System // standard system button
case DetailDisclosure
case InfoLight
case InfoDark
case ContactAdd
}
But in SDK included in Xcode 7, it's back and marked as deprecated.
enum UIButtonType : Int {
case Custom // no button type
@available(iOS 7.0, *)
case System // standard system button
case DetailDisclosure
case InfoLight
case InfoDark
case ContactAdd
static var RoundedRect: UIButtonType { get } // Deprecated, use UIButtonTypeSystem instead
}
You should use System
. If it doesn't fit your needs, do not subclass UIButton
, use custom factory method like this one.
Upvotes: 3
Reputation: 3083
Just use a plain button and cut your own corners:
let button = UIButton()
button.layer.cornerRadius = 3.0
button.clipsToBounds = true
Upvotes: 2