ios - How do you add touch outlets to custom UIView? -


i've created following custom uiview:

// //  yearselectorsegcontrol.swift //  ourdailystrength ios // //  created rob avery on 8/28/17. //  copyright © 2017 rob avery. rights reserved. //  import uikit  @ibdesignable class yearselectorsegcontrol: uiview {      var buttons = [uibutton]()     var selector: uiview!     var sv: uistackview!      var currentposition: int = 0      @ibinspectable     var borderwidth: cgfloat = 0 {         didset {             layer.borderwidth = borderwidth         }     }      @ibinspectable     var bordercolor: uicolor = uicolor.clear {         didset {             layer.bordercolor = bordercolor.cgcolor         }     }      @ibinspectable     var textcolor: uicolor = .lightgray {         didset {             updateview()         }     }      @ibinspectable     var textbackground: uicolor = .clear {         didset {             updateview()         }     }      func updateview() {         // ... code here ...     }      override func draw(_ rect: cgrect) {         layer.cornerradius = 0     } } 

when go interface builder, , try , connect uiview controller, thing allowed outlet. want able connect custom uiview function when it's touched. how do that?

you have subclass uicontrol instead of uiview

@ibdesignable class yearselectorsegcontrol: uicontrol {    ... } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -