A SwiftUI package for creating a custom border and background for any kind of view

PrettyBorder

Description

PrettyBorder is a SwiftUI package for managing an customized border and background at any kind of view.

Preview of end result

Default implementation Customized Parameters

Parameters

Parameters are:

This parameter keeps track of view itself is enabled or not

- isEnabled : Binding<Bool> 

Those are used for customizing the border

- borderCornerRadius: CGFloat
- borderStrokeColor: Color
- borderLineWidth : CGFloat

Color customization for view itself is enabled or not

- disabledColor: Color
- enabledColor: Color

Those are used for giving padding around view itself and border

- paddingFromLeft: CGFloat
- paddingFromTop: CGFloat
- paddingFromRight: CGFloat 
- paddingFromBottom: CGFloat 

Usage

struct ContentView: View {
   
  @State private var isEnabled = false
   
   var body: some View {
       Text("Pretty Border is Awesome!")
           .onTapGesture {
               isEnabled.toggle()
           }
           .modifier(PrettyBorder(isEnabled: $isEnabled,
           borderCornerRadius: nil, borderStrokeColor: nil,
           borderLineWidth: nil, disabledColor: nil, 
           enabledColor: nil, paddingFromLeft: nil,
           paddingFromTop: nil, paddingFromRight: nil, 
           paddingFromBottom: nil))
   }
}

or

struct ContentView: View {

    @State private var isEnabled = false

    var body: some View {
        Text("Pretty Border is Awesome!")
            .onTapGesture {
            isEnabled.toggle()
        }
            .modifier(PrettyBorder(isEnabled: $isEnabled,
            borderCornerRadius: 50, 
            borderStrokeColor: .gray, borderLineWidth: 4,
            disabledColor: .red, enabledColor: .green, 
            paddingFromLeft: 5, 
            paddingFromTop: 30, paddingFromRight: 50, 
            paddingFromBottom: 10))
    }
}

GitHub

https://github.com/ucargiray/PrettyBorder