2016-09-28 64 views
-6

這裏我在阿拉伯語後面寫了button的標題,並且在中間對齊了標題標籤但問題是,有些阿拉伯語後綴觸及按鈕的按鈕邊界和一些頂部邊界按鈕。我該如何解決它如何設置按鈕的標題位置

我的代碼是

optionA.setTitle(Option[0], forState: .Normal) 
optionB.setTitle(Option[1], forState: .Normal) 
optionC.setTitle(Option[2], forState: .Normal) 
optionD.setTitle(Option[3], forState: .Normal) 

野兔optionA,optionB,OptionC中,optionD是按鈕和選項爲阿拉伯語後者

enter image description here

回答

3

使用此

的陣列
let button = UIButton(type: .roundedRect) 
button.frame = CGRect(x: 20, y: 20, width: 200, height: 72) 
button.setTitle("مرحبا", for: .normal) 
button.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0) 
button.contentHorizontalAlignment = .center 
self.view.addSubview(button) 

並將button.titleEdgeInsets更改爲p提及。