NotchButton
安装
NotchButton 通过 CocoaPods 提供使用。要安装它,只需将以下行添加到 Podfile 中
pod 'NotchButton'
需求
- iOS 8.0
屏幕截图

示例
要运行示例项目,请先克隆仓库,然后从 Example 目录运行 pod install
刘海样式手机底部支持。设置高度。自动增加 Bottom SafeAreaInset.bottom
// button1 is Bottom Anchor
let button1 = NotchButton()
button1.translatesAutoresizingMaskIntoConstraints = false
button1.backgroundColor = .gray
button1.setTitle("Notch Area", for: .normal)
button1.height = 40
view.addSubview(button1)
NSLayoutConstraint.activate([
button1.leftAnchor.constraint(equalTo: view.leftAnchor),
button1.rightAnchor.constraint(equalTo: view.rightAnchor),
button1.bottomAnchor.constraint(equalTo: view.bottomAnchor)
])
// button2 is Center Anchor
let button2 = NotchButton()
button2.translatesAutoresizingMaskIntoConstraints = false
button2.backgroundColor = .gray
button2.setTitle("Not Notch Area", for: .normal)
button2.height = 40
view.addSubview(button2)
NSLayoutConstraint.activate([
button2.leftAnchor.constraint(equalTo: view.leftAnchor),
button2.rightAnchor.constraint(equalTo: view.rightAnchor),
button2.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])
作者
- outofcoding, [email protected]
- DH, [email protected]
许可证
NotchButton 在 MIT 许可下可用。更多信息请见 LICENSE 文件。