如何避免 titleEdgeInssets 已弃用警告 / Swift

How can I avoid the titleEdgeInsets' was deprecated warning / Swift

提问人: 提问时间:7/27/2023 更新时间:7/27/2023 访问量:92

问:

我试图让警告消失。'titleEdgeInsets' was deprecated in iOS 15.0: This property is ignored when using UIButtonConfiguration

起初,我用

InfosButton.titleEdgeInsets.top = height*0.08

InfosButton.titleEdgeInsets.right = width*0.04

但是我收到了以下警告:

'titleEdgeInsets' was deprecated in iOS 15.0: This property is ignored when using UIButtonConfiguration

所以我用了:

InfosButton.configuration?.contentInsets = NSDirectionalEdgeInsets(top: height*0.08, leading: width*0.04, bottom: 0, trailing: 0)

但是现在,我无法单独调整图像和按钮标题位置,我只能访问 contentInsets,而不是 titleEdgeInsets 和 imageEdgeInsets。

有人可以帮助我吗?

iOS Swift UIView UIViewController UIBuint

评论

0赞 DonMag 7/27/2023
如果您没有使用按钮,则可以忽略该警告。如果您使用的是按钮,则可以查看 和 .如果这不能给你你想要的输出,你可能想坚持使用“老式的非UIButtonConfiguration”按钮。UIButtonConfigurationUIButtonConfiguration.titlePadding.imagePadding

答: 暂无答案