Hello!
I am working on a custom UITableViewCell and I want to know if it's possible to draw a bottom line on the cell and its accessoryType. Until now, I can't draw the line under the accessory.
Do you how I can implement this?
Post
Replies
Boosts
Views
Activity
I implemented Sign in with Apple but in all cases the button is always black. I would like to show it in light/ dark mode depending on the phone settings.
This is my code:
class MyAuthorizationAppleIDButton: UIButton {
private var authorizationButton: ASAuthorizationAppleIDButton!
@IBInspectable
var cornerRadius: CGFloat = 3.0
@IBInspectable
var authButtonType: Int = ASAuthorizationAppleIDButton.ButtonType.default.rawValue
@IBInspectable
var authButtonStyle: Int = ASAuthorizationAppleIDButton.Style.black.rawValue
override public init(frame: CGRect) {
super.init(frame: frame)
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override public func draw(_ rect: CGRect) {
super.draw(rect)
// Create ASAuthorizationAppleIDButton
authorizationButton = ASAuthorizationAppleIDButton(authorizationButtonType: .signIn, authorizationButtonStyle: .black)
let type = ASAuthorizationAppleIDButton.ButtonType.init(rawValue: authButtonType) ?? .default
let style = ASAuthorizationAppleIDButton.Style.init(rawValue: authButtonStyle) ?? .black
authorizationButton = ASAuthorizationAppleIDButton(authorizationButtonType: type, authorizationButtonStyle: style)
authorizationButton.cornerRadius = cornerRadius
// Show authorizationButton
addSubview(authorizationButton)
// Use auto layout to make authorizationButton follow the MyAuthorizationAppleIDButton's dimension
authorizationButton.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
authorizationButton.topAnchor.constraint(equalTo: self.topAnchor, constant: 0.0),
authorizationButton.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 0.0),
authorizationButton.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: 0.0),
authorizationButton.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: 0.0),
])
}
}
So basically with the code above, I can set on Storyboard the style of the button but it seems that even if I change the value at my code, the result is based on what I chose on Storyboard's variable.
Is there any solution where I would be able to show the button in light/ dark mode depending on the phone settings ?
I have a UIAlertController with preferred style actionSheet and a cancel action with cancel style. The issue I have is that as you can see from the image below, the background colour of the cancel action is slightly different from the other actions.
This is the piece of code I have:
let alert = UIAlertController(title: alertTitle, message: message, preferredStyle: .actionSheet)
let defaultAction = UIAlertAction(title: defaultTitle1, style: .default, handler: { (_) in
self.baseDelegate?.defaultButtonPressed()
})
let default2Action = UIAlertAction(title: defaultTitle2, style: .default, handler: { (_) in
self.baseDelegate?.default2ButtonPressed()
})
let cancelAction = UIAlertAction(title: cancelTitle, style: .cancel, handler: { (_) in
self.baseDelegate?.cancelButtonPressed()
})
alert.setValue(NSAttributedString(string: alert.title!, attributes: [NSAttributedString.Key.font : UIFont.init(name: "SF Compact Display", size: 18) ?? UIFont.systemFont(ofSize: 18.0, weight: .regular), NSAttributedString.Key.foregroundColor : UIColor(named: "Grey#444444") ?? UIColor(red: 68, green: 68, blue: 68, alpha: 1)]), forKey: "attributedTitle")
alert.setValue(NSAttributedString(string: alert.message!, attributes: [NSAttributedString.Key.font : UIFont.init(name: "SF Compact Display", size: 13) ?? UIFont.systemFont(ofSize: 13.0, weight: .regular), NSAttributedString.Key.foregroundColor : UIColor(named: "Grey#444444") ?? UIColor(red: 68, green: 68, blue: 68, alpha: 1)]), forKey: "attributedMessage")
defaultAction.setValue(UIColor(named: "Blue#007AFF"), forKey: "titleTextColor")
default2Action.setValue(UIColor(named: "Grey#444444"), forKey: "titleTextColor")
cancelAction.setValue(UIColor(named: "Grey#444444"), forKey: "titleTextColor")
alert.addAction(defaultAction)
alert.addAction(default2Action)
alert.addAction(cancelAction)
self.present(alert, animated: true, completion: nil)
}
I have run the app on simulator and a device and the result is the same. Do you know how I can have the same background colour on all of my actions ?
Hi all!
I was hoping that in WWDC23 sessions, there would be an announcement on a new API for ultra wide-band and AirTags, in order to have access on developing apps with interaction between iPhones and AirTags using the UWB technology. But, I cannot see anything related to this topic.
Do you think there will be any good news this year ?
Hi there!
I have an issue with UI when updating items in Core Data. Let's say I have three screens A, B and C where A --> B --> C. On screen A, I have a tableView with items from Core Data. On screen C, I have to make some changes on items of Core Data such as update or remove them. So, when I go back to screen A and refresh the tableView in order to get the updated list, the UI is not updated. I debugged the code and I can see that Core Data are correctly updated.
Do you know what the issue is and why the UI is not updated but Core Data is up to date?
Hi! I was wondering if we can get health data from Apple Watch via Internet, without using the Health app and send them to a server.