1

When I'm creating an extension in Xcode and need to call:

segmentedControl.removeBorders()

Where should I call that from?. In viewDidLoad for the view controller's Swift file? as an override func in the view controller's Swift file?. Inserting that after viewDidLoad is giving me a "Method 'segmentedControl' was used as a property; add () to call it" error and when I add the parentheses it gives me a

"Value of tuple type '()' has no member 'removeBorders'" error.

Is it an issue with naming? I named the .swift for deleting the borders/dividers "UISegmentedControl+removeborders.swift". I'm a complete n00b, if that helps to explain why I'm stuck on this. Any help would be greatly appreciated! Thanks!

Reference: The 3rd answer listed for this question regarding removing the border/dividers from UISegmentedControl: Remove UISegmentedControl separators completely. (iphone)

Community
  • 1
  • 1
Bob F.
  • 93
  • 1
  • 11

1 Answers1

0

In my current project, I've subclassed it, so the call is made in the initializer:

class SegmentedControl: UISegmentedControl {
    override init(items: [Any]?) {
        super.init(items: items)
        segmentedControlInit()
    }
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        segmentedControlInit()
    }
    private func segmentedControlInit() {
        removeBorders()
    }
}

But doing it from viewDidLoad should be fine as well.

Cœur
  • 37,241
  • 25
  • 195
  • 267