UIButtonをStoryBoardではなく、
コードで直接生成し、押下時にボタンのタイトルがハイライトする処理を書いたところ、
ボタンがハイライトするタイミングがStoryBoardのボタンに比べ0.5秒ほど遅れてしまい困っています。
コードは以下の通りです。
let button = UIButton() button.setTitle("タイトル", forState: .Normal) button.titleLabel!.font = UIFont(name: "Helvetica-Bold",size : CGFloat(24.0)) button.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0) button.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Left button.frame = CGRectMake(0,0,862,55) button.layer.position = CGPoint(x: self.view.frame.width/2, y: y) button.layer.cornerRadius = 5 button.tag = 1 button.exclusiveTouch = true //こちらで押下時の色を変える設定をしています。 button.setTitleColor(UIColor.whiteColor(), forState: .Normal) button.setTitleColor(UIColor.redColor(), forState: .Highlighted) button.backgroundColor = UIColor.blueColor() button.addTarget(self, action:#selector(ResultView.tapped(_:)), forControlEvents: .TouchUpInside) self.view.addSubview(button)
原因をご存知の方いらっしゃいませんか?
ご教授願います。
回答1件
あなたの回答
tips
プレビュー