IBOutletCollection set ordering in Interface Builder

前端 未结 10 1071
我寻月下人不归
我寻月下人不归 2020-11-30 22:20

I am using IBOutletCollections to group several Instances of similar UI Elements. In particular I group a number of UIButtons (which are similar to buzzers in a quiz game) a

10条回答
  •  攒了一身酷
    2020-11-30 23:07

    I used the extension proposed by @scott-gardner to order Image Views in order to display counters using individual png images of dot-matrix digits. It worked like a charm in Swift 5.

    self.dayDigits.sortUIViewsInPlaceByTag()
    
    func updateDayDigits(countString: String){
            for i in 0...4 {
                dayDigits[i].image = offDigitImage
            }
            let length = countString.count - 1
            for i in 0...length {
                let char = Array(countString)[length-i]
                dayDigits[i].image = digitImages[char.wholeNumberValue!]
            }
        }
    

提交回复
热议问题