- FontAwesome support
- view shadow
- toast show and with completion
- network helper
- much more
add font awesome ttf file to your project also mark them in your info.plist
dependencies: [ .package(url: "https://github.com/sahibhussain/SahibHelper.git", .upToNextMinor(from: "1.3.0")) ]
💡 ** Tip:** use the latest release version written on the badge.
let designHelper = DesignHelper.shared let networkHelper = NetworkHelper.shared
Custom Switch as SahibSwitch which inherits UIView
Available Alignment Options
You can use any combination of horizontal and vertical alignment to achieve your desired layout.
horizontalAlignment = .left
horizontalAlignment = .right
horizontalAlignment = .justified
horizontalAlignment = .leading
Renders as either
.right, depending on the user's layout direction (UIApplication.shared.userInterfaceLayoutDirection):
horizontalAlignment = .trailing
Renders as either
.right, depending on the user's layout direction (UIApplication.shared.userInterfaceLayoutDirection).
verticalAlignment = .top
verticalAlignment = .center
verticalAlignment = .bottom
Setup in Interface Builder
You have a collection view in Interface Builder and setup its data source appropriately. Run the app and make sure everything works as expected (except the cell alignment).
In the Document Outline, select the collection view layout object.
In the Identity Inspector, set the layout object's custom class to
Add and customize the following code to your view controller's
let alignedFlowLayout = collectionView?.collectionViewLayout as? AlignedCollectionViewFlowLayout alignedFlowLayout?.horizontalAlignment = .left alignedFlowLayout?.verticalAlignment = .top
If you omit any of the last two lines the default alignment will be used (horizontally justified, vertically centered).
💡 Pro Tip: Instead of type-casting the layout as shown above you can also drag an outlet from the collection view layout object to your view controller.
Setup in code
Create a new
AlignedCollectionViewFlowLayoutobject and specify the alignment you want:
let alignedFlowLayout = AlignedCollectionViewFlowLayout(horizontalAlignment: .left, verticalAlignment: .top)
Either create a new collection view object and and initialize it with
let collectionView = UICollectionView(frame: bounds, collectionViewLayout: alignedFlowLayout)
collectionViewLayoutproperty of an existing collection view:
yourExistingCollectionView.collectionViewLayout = alignedFlowLayout
Implement your collection view's data source.
Run the app.
AlignedCollectionViewFlowLayout distributes the cells horizontally with a constant spacing which is the same for all rows. You can control the spacing with the
alignedFlowLayout.minimumInteritemSpacing = 10
Despite its name (which originates from its superclass
UICollectionViewFlowLayout) this property doesn't describe a minimum spacing but the exact spacing between the cells.
The vertical spacing between the lines works exactly as in
alignedFlowLayout.minimumLineSpacing = 10
You may find interesting
Added Headers - 2020-06-05 09:25:49
Added Header Support in API Requests
Added CollectionViewLayout Allignment - 2020-04-16 09:24:32
Now you can Align you cell to left, right, top, bottom instead of the collectionView default behaviour
Error Resolved - 2020-04-13 09:15:59
resolved error while importing package
Initial Release - 2020-04-13 07:47:17
this is an initial release with all the neccessary update