使用方法
let configure = PXPullConfigure()
configure.apexPoint = CGPoint(x: UIScreen.main.bounds.width - 45, y: 45)
let view = PXPullView.init(configure: configure, titileArr: ["测试1","测试2","测试3","测试4","测试5"])
view.show()
configure为view的配置参数,apexPoint为三角的顶点位置,可选的配置参数如下
class PXPullConfigure {
var width: CGFloat = 100
var height: CGFloat = 200
var apexPoint: CGPoint = CGPoint(x: 0, y: 0) //三角顶点
var scale: CGFloat = 0.25 //以箭头为界 小边和长边的比例
var fillColor: UIColor = UIColor.white //填充颜色
var shadowColor: UIColor = UIColor.black.withAlphaComponent(0.25) //遮罩颜色
var shadowFatherView: UIView = UIApplication.shared.keyWindow! //添加的view
}
对于越界的配置参数进行了处理,默认距离父View的内边距为16
if configure.width > UIScreen.main.bounds.width/2 {
configure.width = UIScreen.main.bounds.width/2
}
if configure.height > UIScreen.main.bounds.height/2 {
configure.height = UIScreen.main.bounds.height/2
}
if configure.scale >= 1 {
configure.scale = 0.25
}
if self.configure.apexPoint.x == UIScreen.main.bounds.width/2 {
//btn在屏幕中间
orginX = (UIScreen.main.bounds.width - configure.width)/2
}else if self.configure.apexPoint.x < UIScreen.main.bounds.width/2{
//btn在屏幕左边
orginX = self.configure.apexPoint.x - configure.width * configure.scale
if orginX < 16 {
//左边界超出界面
orginX = 16
}
}else if self.configure.apexPoint.x > UIScreen.main.bounds.width/2{
//btn在屏幕右边
orginX = self.configure.apexPoint.x + configure.width * (1 - configure.scale)
if orginX + configure.width > UIScreen.main.bounds.width - 16 {
//右边界超出界面
orginX = UIScreen.main.bounds.width - 16 - configure.width
}
}
效果图如下
GitHub地址
✨期待你们的小星星