I\'ve made a series of checkboxes in UiKit with UIButtons:
@IBOutlet weak var Box1: UIButton!
@IBOutlet weak var Box2: UIButton!
@IBOutlet weak var Box3: UIB
I have created array of checkboxes(buttons) along with text(labels). You can select and deselect any button.
func addCheckBoxButtonsForSecondContainerView ()
{
var xPosition = 0
var yPosition = 0
for i in 0..
//Next we see here action for the buttons(checkboxes)
@objc func secondViewButtonAction(_ sender: UIButton)
{
if arrayofSelectedIndexes.contains(sender.tag)
{
for i in 0..
}
//this is for title label action
@objc func secondViewLabelAction(_ sender: UITapGestureRecognizer)
{
for subview in self.secondContainerView.subviews {
if let button = subview as? UIButton {
let searchlbl:UILabel = (sender.view as! UILabel) //just to get sender tag
if searchlbl.tag == subview.tag
{
if arrayofSelectedIndexes.contains(searchlbl.tag)
{
for i in 0..
Let me know if you need more clarification. User can click on button or title label. Same action will be performed. I'm attaching the screenshot here for output. [1]: https://i.stack.imgur.com/cXoww.png