Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swiftui rounded specific corner

extension View {
    func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View {
        clipShape( RoundedCorner(radius: radius, corners: corners) )
    }
}
Comment

how to add corner in swiftui

extension UIView {
   func roundCorners(corners: UIRectCorner, radius: CGFloat) {
        let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
        let mask = CAShapeLayer()
        mask.path = path.cgPath
        layer.mask = mask
    }
}
Comment

swiftui rounded specific corner

struct RoundedCorner: 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)
    }
}
Comment

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 :: convert uiimage to data swift 
Swift :: swift ui view 
Swift :: struct vs class in swift 
Swift :: two value sum 
Swift :: share local storage wkwebview swift 
Swift :: SwiftCSV and RealmSwift library 
Swift :: swift comment 
Swift :: table view content size not return correctly 
Swift :: swift from 1 to 01 
Swift :: Swift nested if Statement 
Swift :: Swift Join Two Strings 
Swift :: auto layout issue in tableview 
Swift :: swift variables 
Swift :: separator style swiftui list 
Swift :: access tuple elements 
Swift :: swift constants 
Swift :: Swift Nested Tuple 
Swift :: check and uncheck cells in uitableview swift 5 
Swift :: Swift Find Number of Array Elements 
Swift :: ln -s ~/.platformio/penv/bin/platformio /usr/local/bin/platformio ln -s ~/.platformio/penv/bin/pio /usr/local/bin/pio ln -s ~/.platformio/penv/bin/piodebuggdb /usr/local/bin/piodebuggdb 
Swift :: swift collectionview ispagingenabled change page size 
Swift :: Swift Character 
Swift :: .next() enum swift 
Ruby :: rails mimemagic issue 
Ruby :: remove ruby 
Ruby :: ruby file write 
Ruby :: add timezone in rails 
Ruby :: is there a way of changing the key of a hash 
Ruby :: ruby get the number of same element in array 
Ruby :: ruby change directory 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =