次のようにフォントを設定することができます。
button.setImage(UIImage(named: "imageName") for: .normal)
button.setTitle("the title string", for: .normal)
とボタンのテキストフォント:
:あなたは画像やボタンのテキストの位置を交換することができ
button.setTitleColor(UIColor.red, for: .highlighted)
のObjective-Cで:
button.titleLabel?.font = UIFont(name: "font string you want", size: 18)
強調表示された状態の色
_titleViewBtn.size=CGSizeMake(100, 20);
CGFloat imgX=_titleViewBtn.imageView.frame.origin.x;
CGFloat titleX=_titleViewBtn.titleLabel.frame.origin.x;
if (imgX<titleX) {
CGRect titleFrame=_titleViewBtn.titleLabel.frame;
titleFrame.origin.x=imgX;
_titleViewBtn.titleLabel.frame=titleFrame;
CGRect imgFrame=_titleViewBtn.imageView.frame;
imgFrame.origin.x=CGRectGetMaxX(_titleViewBtn.titleLabel.frame);
_titleViewBtn.imageView.frame=imgFrame;
}
コードを表示できますか? –
私は –
を表示しようとします。クリックしてVCを変更したいのであれば、なぜボタンの色を変更する必要がありますか? –