gpt4 book ai didi

ios - 如何将 UIButton 与自定义类一起使用?

转载 作者:行者123 更新时间:2023-11-30 11:02:12 26 4
gpt4 key购买 nike

我目前正在开发一个应用程序,尽管我可以选择“RoundedButton”类,但我的自定义类似乎没有反射(reflect)在 UIButton 上。这是我的应用程序的屏幕截图:

Appscreenshot这是类名设置的截图:

class name setting

这是我的自定义类的代码:

class RoundedButton: UIButton {
override func layoutSubviews() {
super.layoutSubviews()
let radius: CGFloat = self.bounds.size.height / 10.0
self.layer.cornerRadius = radius
self.clipsToBounds = true
}
}

我已经筛选了其他网站,但似乎无法使其正常工作。

最佳答案

我尝试了你的代码,它工作正常,将你的 UIButton 设置为自定义类型

enter image description here

Sometimes Xcode does not save the UIButton Custom Class correctly, try restarting Xcode and check if the class RoundedButton is still selected for that Button.

关于ios - 如何将 UIButton 与自定义类一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53209728/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com