我正在尝试自定义 FBLoginButton 的布局,使其与我拥有的其他登录按钮相匹配。
我创建了一个自定义类子类FBLoginButton并添加了我自己的标签和图像。
class CustomFBLoginButton: FBLoginButton {
private let myTitleLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 1
label.textAlignment = .center
return label
}()
private let myIconImage: UIImageView = {
let imageView = UIImageView()
imageView.contentMode = .scaleAspectFit
return imageView
}()
public func setupLayout() {
addSubview(myTitleLabel)
addSubview(myIconImage)
myIconImage.translatesAutoresizingMaskIntoConstraints = false
myTitleLabel.translatesAutoresizingMaskIntoConstraints = false
//auto layout
...
...
}
}
有了这个自定义类按钮,我明白了。
我添加的 UILabel 和 UIImage 与FBLoginButton. 现在我想我需要删除 FBLoginButton 的默认 UI 元素或删除我自己的 UI 元素并调整默认 UI 元素。
我该如何处理?我可以访问FBLoginButton自动布局的 UI 元素并覆盖它吗?

