使用方法
let configure = PXPullConfigure()
configure.apexPoint = CGPoint(x: UIScreen.main.bounds.width - 45, y: 45)
let view = PXPullView.init(configure: configure, titileArr: ["測(cè)試1","測(cè)試2","測(cè)試3","測(cè)試4","測(cè)試5"])
view.show()
configure為view的配置參數(shù)咏闪,apexPoint為三角的頂點(diǎn)位置帆锋,可選的配置參數(shù)如下
class PXPullConfigure {
var width: CGFloat = 100
var height: CGFloat = 200
var apexPoint: CGPoint = CGPoint(x: 0, y: 0) //三角頂點(diǎn)
var scale: CGFloat = 0.25 //以箭頭為界 小邊和長(zhǎng)邊的比例
var fillColor: UIColor = UIColor.white //填充顏色
var shadowColor: UIColor = UIColor.black.withAlphaComponent(0.25) //遮罩顏色
var shadowFatherView: UIView = UIApplication.shared.keyWindow! //添加的view
}
對(duì)于越界的配置參數(shù)進(jìn)行了處理玛痊,默認(rèn)距離父View的內(nèi)邊距為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地址
?期待你們的小星星