2016-05-13 59 views
0

我在tableViewCell中編輯和刪除了tableViewRowAction。目前我使用內置的emojis作爲我的標題,但它太小了。如何使字體變大?UITableViewRowAction在Swift中自定義標題字體大小

我知道我們只能在tableViewRowAction中定製有限數量的東西。但是有沒有辦法繞過它來讓標題字體更大?

我檢查其他線程,其中大部分用於:

UIButton.appearance().setAttributedTitle(NSAttributedString(string: "Your Button", attributes: attributes), forState: .Normal) 

與確定過程的字體大小的一組屬性。但是,這會影響所有按鈕,這並不好。

任何幫助非常感謝!謝謝!

回答

0

您正在將其設置爲UIButton,因此它爲所有UIButton對象設置。

你可以將它設置爲如特定按鈕對象,

let myButton: UIButton = UIButton() //your button here 
    let attributedStr: NSAttributedString = NSAttributedString() 
    myButton.setAttributedTitle(attributedStr, forState: .Normal) 

更新:

您可以設置標題屬性串。

對於檢查Apple documentation和參考this answer更多細節

希望這將有助於:)

+0

嗨感謝您的答覆。 (:但是,UITableViewRowAction不是UIButton類型,所以我不能使用UIButton路徑來設置標題大小。 –

+0

檢查我的更新回答 – Lion

+0

謝謝!我明白,但我該如何設置字符串類型的標題爲NSAttributedString?它給我一個錯誤。這是我的代碼:'let attributes = [NSFontAttributeName:UIFont.systemFontOfSize(20)] as Dictionary! let attributedStringRemove = NSAttributedString(string:「✖︎」,attributes:attributes)'和然後在這裏添加屬性字符串到標題:'let removeAction = UITableViewRowAction(style:.Default,title:attributedStringRemove)' –