Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

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))
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: Incompatible Swift version - framework was built with 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1) and the local version is 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57) 
Swift :: Swift is case-sensitive. So A and a are different variables 
Swift :: uitableview total number of rows 
Swift :: swift md5 cryptokit 
Swift :: how to darken view swiftui 
Swift :: SwiftUI cant tap in spacer of HStack 
Swift :: Assignment Operators Swift 
Swift :: swift core data order by 
Swift :: get character at specifiic location swift 
Swift :: Swift Function With Argument Label 
Swift :: how to check if not running in debufgger swift 
Swift :: uilabel without constraint 
Swift :: Swift Labeled Statement with break 
Swift :: how to get ride of back button in navbar xcode 
Swift :: convert dictionary to data 
Swift :: swift function return type 
Swift :: print 1 line swift 
Swift :: Compare AnyObjects en Swift 
Swift :: circular array swift 
Ruby :: how to check if data is an array or not ruby 
Ruby :: rails hidden field 
Ruby :: How can I rename a database column in a Ruby on Rails migration? 
Ruby :: rails validators 
Ruby :: rails remove foreign key 
Ruby :: how to get new line to display in rails 
Ruby :: validates inclusion of rails 
Ruby :: ruby sort array numerically 
Ruby :: ruby hash.each 
Ruby :: rbenv and ruby different versions 
Ruby :: ruby while 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =