Browse Questions
- Every UIView has a CALayer that does the actual drawing and compositing.
- Use Secure Message when two parties with separate key pairs exchange data, and Secure Cell when a single party encrypts data for itself.
- Use Fastlane's firebaseappdistribution plugin to build an Ad Hoc .ipa and upload it to Firebase — testers receive a download link by email within minutes.
- Store tokens securely in the Keychain, attach them to requests via a header, and refresh automatically when a 401 is received.
Answer:
Every UIView has a CALayer that does the actual drawing and compositing. UIView is a wrapper that adds event handling on top of CALayer.
Code Example:
let view = UIView()
// Common layer properties
view.layer.cornerRadius = 12
view.layer.borderWidth = 1
view.layer.borderColor = UIColor.systemBlue.cgColor
view.layer.shadowColor = UIColor.black.cgColor
view.layer.shadowOpacity = 0.2
view.layer.shadowRadius = 4
view.layer.shadowOffset = CGSize(width: 0, height: 2)
// Clip to bounds — apply on both for correctness
view.clipsToBounds = true // UIView level
view.layer.masksToBounds = true // CALayer level
// CALayer animations — lower level than UIView.animate
let animation = CABasicAnimation(keyPath: "opacity")
animation.fromValue = 1.0
animation.toValue = 0.0
animation.duration = 0.3
view.layer.add(animation, forKey: "fade")
Key distinction: UIView is on the main thread; CALayer can render on background threads.