An easy to use drop-in view to create a beautiful card style effect with a title placeholder and body content.
- Supports IBDesignable
- Full controls available in storyboard
- Can be used programatically
- Swift 5 support
- Resolved an issue with multiple
SceneDelegateclass definitions causing build errors. - Ensured there is only one valid
SceneDelegatein the project, supporting the UIScene lifecycle.
Summary:
- The project now properly supports the UIScene lifecycle with a single
SceneDelegateimplementation. - This improves compatibility with modern iOS multi-window environments and prevents runtime and compilation errors related to duplicate class definitions.
- Compatible with iOS 13.0 and later.
- Compatible with iPadOS 13.0 and later.
- Supports modern UIScene lifecycle for multi-window environments.
- Set capsule background
- Set Place holder and content text
- Set Place holder and content text allignment
- Set Place holder and content text size
- Set Shadow and corner radius
- A handy cross button with toggle option
- Drag and drop the two files CapsuleView Files namely, CapsuleView.swift & CapsuleView.xib into your project.
- Open storyboard, select the view you want to customize and change it's custom class to CapsuleView as shown:
-
Make changes to the view in storyboard
-
Open your viewcontroller, create an outlet to the selected view and call the setupView() method as shown:
- Just use the helper init method to set the view and make the customization.
- Add the capsule view to your view as shown below:
//MARK: Use for adding view dynamically
let capsuleViewFrame = CGRect(x: 50, y: 200, width: 300, height: 300)
let capsuleView = CapsuleView(placeholderText: "Address", contentText: "31st street,\nPark Avenue,\n 46/6,\n New York,\n USA", cardColor: UIColor(red: 0.075, green: 0.561, blue: 0.325, alpha: 1.00), textColor: UIColor.white, shadowColor: UIColor.darkGray, shadowOpacity: 9, shadowRadius: 9, cardRadius: 9, shadowOffset: CGSize(width: 0, height: 0), textAllignment: 1, showCross: false, viewFrame: capsuleViewFrame,placeHolderSize:4,titleSize: 3)
self.view.addSubview(capsuleView)
self.view.bringSubviewToFront(capsuleView)




