swift扩展UIview
对于swift的UIView做⼀个简单的扩展⽅便使⽤
废话不多说直接上⼲货
extensionUIView{
//MARK:坐标尺⼨
varorigin:CGPoint{
get{
}
t(newValue){
varrect=
=newValue
=rect
}
}
varsize:CGSize{
get{
}
t(newValue){
varrect=
=newValue
=rect
}
}
varleft:CGFloat{
get{
.x
}
t(newValue){
varrect=
.x=newValue
=rect
}
}
vartop:CGFloat{
get{
.y
}
t(newValue){
varrect=
.y=newValue
=rect
}
}
varright:CGFloat{
get{
return(.x+)
}
t(newValue){
varrect=
.x=()
=rect
}
}
varbottom:CGFloat{
get{
return(.y+)
}
t(newValue){
varrect=
.y=()
=rect
}
}
//MARK:-size
funcwidth()->CGFloat{
}
funcheight()->CGFloat{
}
//MARK:-位移
//移动到指定中⼼点位置
funcmoveToPoint(point:CGPoint)->Void
{
varcenter=
center.x=point.x
center.y=point.y
=center
}
//缩放到指定⼤⼩
funcscaleToSize(scale:CGFloat)->Void
{
varrect=
*=scale
*=scale
=rect
}
//MARK:-⽑玻璃效果
//⽑玻璃
funceffectViewWithAlpha(alpha:CGFloat)->Void
{
leteffect=(style:)
leteffectView=(effect:effect)
=
=alpha
view(effectView)
}
//MARK:-边框属性
//圆⾓边框设置
funclayer(radius:CGFloat,borderWidth:CGFloat,borderColor:UIColor)->Void
{
if(0.0
{
Radius=radius
oBounds=true
oBounds=true
}
if(0.0
{
Color=r
Width=borderWidth
}
}
//MARK:-翻转
//旋转旋转180度M_PI
funcviewTransformWithRotation(rotation:CGFloat)->Void
{
orm=CGAffineTransform(rotationAngle:rotation);
}
}
//缩放
funcviewScaleWithSize(size:CGFloat)->Void
{
orm=By(x:size,y:size);
}
//⽔平,或垂直翻转
funcviewFlip(isHorizontal:Bool)->Void
{
if(isHorizontal)
{
//⽔平
orm=By(x:-1.0,y:1.0);
}
el
{
//垂直
orm=By(x:1.0,y:-1.0);
}
}
}
本文发布于:2022-12-09 20:01:36,感谢您对本站的认可!
本文链接:http://www.wtabcd.cn/fanwen/fan/88/74619.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |