Answers for "rounded rectangle in swift ui"

2

add corner radius to uiview swift

view.layer.cornerRadius = 25
view.layer.masksToBounds = true
Posted by: Guest on April-03-2020
0

swiftui rectangle top corners radius

struct CornerRadiusStyle: ViewModifier {
    var radius: CGFloat
    var corners: UIRectCorner

    struct CornerRadiusShape: Shape {

        var radius = CGFloat.infinity
        var corners = UIRectCorner.allCorners

        func path(in rect: CGRect) -> Path {
            let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
            return Path(path.cgPath)
        }
    }

    func body(content: Content) -> some View {
        content
            .clipShape(CornerRadiusShape(radius: radius, corners: corners))
    }
}

extension View {
    func cornerRadius(radius: CGFloat, corners: UIRectCorner) -> some View {
        ModifiedContent(content: self, modifier: CornerRadiusStyle(radius: radius, corners: corners))
    }
}
Posted by: Guest on August-31-2021

Code answers related to "rounded rectangle in swift ui"

Code answers related to "Swift"

Browse Popular Code Answers by Language