我正在使用一个UIButton作为标签来显示一些数字。每当函数被调用以重置此按钮的标题时,它都会闪烁。这不会影响功能,但会损害用户体验。我想知道是否有办法停止UIButton这种突出行为?
提前感谢!
编辑:以下是我简单调用委托方法updateDigits以刷新按钮标题的代码。
提前感谢!
编辑:以下是我简单调用委托方法updateDigits以刷新按钮标题的代码。
class ViewController: UIViewController, UIPopoverPresentationControllerDelegate, DigitsEntryViewDelegate {
@IBOutlet weak var tipField1: UIButton!
@IBOutlet weak var tipField2: UIButton!
var buttonsArray = [UIButton]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.tipField1.tag = 0
self.tipField2.tag = 1
self.tipField1.addTarget(self, action: "inputFieldClicked:", forControlEvents: UIControlEvents.TouchUpInside)
self.tipField2.addTarget(self, action: "inputFieldClicked:", forControlEvents: UIControlEvents.TouchUpInside)
self.buttonsArray.append(self.tipField1)
self.buttonsArray.append(self.tipField2)
}
func inputFieldClicked(sender: UIButton) {
let anchor: UIView = sender
let viewControllerForPopover = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("DigitEnter") as! DigitsEntryViewController
// set popover API values
viewControllerForPopover.currentDigitsString = sender.currentTitle
viewControllerForPopover.tagNumber = sender.tag
viewControllerForPopover.delegate = self
viewControllerForPopover.preferredContentSize = CGSizeMake(240, 320)
let popover = UIPopoverController(contentViewController:viewControllerForPopover)
popover.presentPopoverFromRect(anchor.frame, inView: anchor.superview!, permittedArrowDirections: UIPopoverArrowDirection.Down, animated: false)
}
func updateDigits(returnedDigits: String, tagNumber: Int) {
self.buttonsArray[tagNumber].setTitle(returnedDigits, forState: UIControlState.Normal)
}
}