Thursday, December 8, 2016

Part 3 - UIView's Tag Property

The Tag property is a number and when used with the corresponding viewWithTag function one can access a specific subview without the need for an outlet.

Example

 
override func viewDidLoad() {
    super.viewDidLoad()
    
    let label = view.viewWithTag(1) as! UILabel
    label.text = "New text here"
}
 

Observations

  • You can give the same Tag to multiple views
  • The first view in the document outline matching the Tag number is selected when viewWithTag is used


(Swift 3.0)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

SwiftUI Search & Filter with Combine - Part 3 (iOS, Xcode 13, SwiftUI, 2...

In part 3 of the Searchable video series, I show you how to use Combine in #SwiftUI for the search and filter logic connected to the searcha...