UIView animateWithDuration doesn’t animate cornerRadius variation

tl;dr: Corner radius is not animatable in animateWithDuration:animations:. What the documentation says about view animations. As the section on Animations in the “View Programming Guide for iOS” says Both UIKit and Core Animation provide support for animations, but the level of support provided by each technology varies. In UIKit, animations are performed using UIView objects … Read more

Swift – Problems with corner radius and drop shadow

The following Swift 5 / iOS 12 code shows how to set a subclass of UIButton that allows to create instances with rounded corners and shadow around it: import UIKit final class CustomButton: UIButton { private var shadowLayer: CAShapeLayer! override func layoutSubviews() { super.layoutSubviews() if shadowLayer == nil { shadowLayer = CAShapeLayer() shadowLayer.path = UIBezierPath(roundedRect: … Read more

Round Specific Corners SwiftUI

Using as a custom modifier You can use it like a normal modifier: .cornerRadius(20, corners: [.topLeft, .bottomRight]) Demo You need to implement a simple extension on View like this: extension View { func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View { clipShape( RoundedCorner(radius: radius, corners: corners) ) } } And here is the struct … Read more