https://github.com/rastaman111/tagsflowlayout
This implementation is built using a UICollectionView and a custom flowLayout.
https://github.com/rastaman111/tagsflowlayout
animated collectionview ios swift tag uicollectionview uicollectionviewflowlayout uikit
Last synced: 4 months ago
JSON representation
This implementation is built using a UICollectionView and a custom flowLayout.
- Host: GitHub
- URL: https://github.com/rastaman111/tagsflowlayout
- Owner: rastaman111
- License: mit
- Created: 2022-04-26T13:43:06.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-27T08:58:09.000Z (over 3 years ago)
- Last Synced: 2025-05-13T12:50:46.174Z (5 months ago)
- Topics: animated, collectionview, ios, swift, tag, uicollectionview, uicollectionviewflowlayout, uikit
- Language: Swift
- Homepage:
- Size: 4.04 MB
- Stars: 19
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# TagsFlowLayout
This implementation is built using a `UICollectionView` and a custom flowLayout.
### Horizontal Alignment:
* `horizontalAlignment = .left`
![]()
* `horizontalAlignment = .right`
![]()
* `horizontalAlignment = .center`
![]()
### Inserting and Deleting tags
![]()
# Table of contents
* [Requirements](#requirements)
* [Installation](#installation)
- [CocoaPods](#cocoapods)
- [Swift Package Manager](#swift-package-manager)
- [Carthage](#carthage)
- [Manually](#manually)
* [Usage](#usage)
* [License](#license)
* [Donation](#donation)## Requirements
* iOS 11.0+
* Swift 5## Installation
### CocoaPods
Add Instructions to your Podfile:```ruby
pod 'TagsFlowLayout'
```Then, run the following command:
```bash
$ pod install
```### Swift Package Manager
In Xcode, use File > Swift Packages > Add Package Dependency and use `https://github.com/rastaman111/TagsFlowLayout`.### Carthage
To install with [Carthage](https://github.com/Carthage/Carthage), simply add the following line to your Podfile:
```ruby
github "rastaman111/TagsFlowLayout"
```### Manually
If you prefer not to use any of dependency managers, you can integrate manually. Put `Sources/TagsFlowLayout` folder in your Xcode project. Make sure to enable `Copy items if needed` and `Create groups`.## Usage
To use `TagsFlowLayout` inside your `UIViewController`:```swift
import TagsFlowLayoutclass ViewController: UICollectionViewController {
override func viewDidLoad() {
super.viewDidLoad()
let tagsFlowLayout = TagsFlowLayout(alignment: .left ,minimumInteritemSpacing: 10, minimumLineSpacing: 10, sectionInset: UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10))
collectionView.collectionViewLayout = tagsFlowLayout
// register cell
collectionView.register(nib: UINib(nibName: "ExampleCell", bundle: nil), forCellWithReuseIdentifier: "ExampleCell")
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ExampleCell", for: indexPath) as! ExampleCell
cell.maxWidth = collectionView.bounds.width - 30return cell
}
}
```
```swift
class TagCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var tagLabel: UILabel!
@IBOutlet private var maxWidthConstraint: NSLayoutConstraint! {
didSet {
maxWidthConstraint.isActive = false
}
}
var maxWidth: CGFloat? = nil {
didSet {
guard let maxWidth = maxWidth else {
return
}
maxWidthConstraint.isActive = true
maxWidthConstraint.constant = maxWidth
}
}
}
```
## License
TagsFlowLayout is available under the MIT license. See the LICENSE file for more info.