contentEdgeInsets在 iOS 15 中已棄用,現在我self.configuration.contentInsets用來設定按鈕的填充。但是在我設定完配置后,我仍然需要呼叫self.configuration.contentInsets.top/bottom/leading/trailing來計算intrinsicContentSize,但總是回傳0。作業正常,self.contentEdgeInsets.left/right/top/bottom但我不想使用它,因為它已經被棄用了,還有其他解決方案嗎?
uj5u.com熱心網友回復:
現在我
self.configuration.contentInsets用來設定按鈕的填充。
您不能通過 aUIButton已經擁有的屬性值(指標)來更改配置。configuration相反,您應該通過設定屬性作為一個整體來觸發 setter 方法:
UIButtonConfiguration *config = _mButton.configuration;
config.contentInsets = NSDirectionalEdgeInsetsMake(10, 10, 10, 10);
_mButton.configuration = config;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/513028.html
標籤:IOS目标-c
下一篇:leetcode 236. Lowest Common Ancestor of a Binary Tree 二叉樹的最近公共祖先(中等)
