This article is 10 years old
The content here might be outdated as technology and best practices evolve quickly. While the concepts may still be valuable, please verify the information against current documentation and standards.
TNSwiftyCheckboxGroup, create checkbox groups in Swift
TNCheckboxGroup
Last year I published TNCheckboxGroup for Objective-C, but I had a few comments it didn’t work when using with Swift. So I just published a Swift version on Github. This versions leverages UICollectionView to handle big sets of checkboxes. TNSwiftyCheckboxGroup, create checkbox groups in Swift.
Introducing TNSwiftyCheckboxGroup - checkbox groups in Swift

All the details about implementing the view controller are explained in the README of the Github project. There is an example project which shows you the different options.
Prerequisites
-
Xcode
-
iOS8+
-
Swift project
Features
-
3 predefined styles (checkbox, radio button, image)
-
Possibility to add your own checkbox styles
-
Delegate object to get informed when your checkbox group changes
-
Storyboards & programmatic approach
-
Works in both orientations (landscape / portrait)
-
AutoLayout behind the scenes
Options
There are quite a few ways to customize the existing styles. Here is a brief overview:
-
CollectionViewWidthOfCell : The width of the checkbox cell. Default: 150
-
CollectionViewBackgroundColor : The background color of the collection view. Default: White
-
FontOfNameLabel : The font of the name label. Default: System 12pt
-
FontColorOfNameLabel : The font color of the name label. Default: #333333
-
PreferredWidthOfNameLabel : The preferred width for the name label. Default: 100
-
CheckboxOuterColor : The outer color for the built-in checkbox types. Default: #333333
-
CheckboxInnerColor : The outer color for the built-in checkbox types. Default: White
-
CheckboxPadding : The padding between the inner and outer views of the build-in checkbox types. Default: 5
-
CheckboxUncheckedImageName : The image name for the unchecked image (defined in your image assets catalog), if you are using the
TNSwiftyImageCheckboxViewstyle. Default: unchecked-image -
CheckboxCheckedImageName : The image name for the checked image (defined in your image assets catalog), if you are using the
TNSwiftyImageCheckboxViewstyle. Default: checked-image
To use these options, you just have to implement the style datasource method.
func styleDictionaryForCheckboxView() -> [String : AnyObject] {
return [
TNSwiftyCheckboxStyleOptions.CheckboxOuterColor : UIColor.redColor(),
]
}
Swift
I hope you will like it. If you have any requests, please post them via the comments below or add an issue on Github.
About the Author
👋 Hi, I'm Frederik Jacques, a passionate iOS developer and entrepreneur with over a decade of experience building innovative mobile applications.
I love creating apps that solve real problems and bring joy to users. From educational tools to creative meme makers, I'm always exploring new ways to blend technology with user experience. When I'm not coding, you'll find me sharing insights about iOS development, app monetization, and the indie developer journey.