RicRibbonTag 1.3.0

RicRibbonTag 1.3.0

测试已测试
语言语言 SwiftSwift
许可协议 MIT
发布最后发布2016年10月
SwiftSwift 版本3.0
SPM支持 SPM

Ricard 维护。



  • Ricard

RicRibbonTag

为现有视图添加类似缎带形状的标签的库

captura de pantalla 2016-09-02 a las 16 55 16 captura de pantalla 2016-09-06 a las 8 30 43 captura de pantalla 2016-09-02 a las 17 04 40

安装

手动

只需将 RicRibbonLabel.swift 和 RicRibbonTag.swift 复制到您的项目中

快速示例

let ribbon = RicRibbonTag()

ribbon.type = .TopLeftCorner
ribbon.label.text = "20% Discount"
ribbon.originDistance = 40
ribbon.ribbonWidth = 40
ribbon.label.textColor = UIColor.whiteColor()

ribbon.wrap(containerView)

captura de pantalla 2016-09-02 a las 16 55 16

属性

label

标签在内部渲染的标签,可用于修改其文本和字体。它的 frame、origin 和 transform 在内部修改,不应进行编辑

decorationSize

缎带的装饰在边缘的外部的大小,禁用 clipstobounds 会在父视图中使它们可见

ribbonWidth

缎带的宽度,如果启用自动调整大小,则忽略此值

ribbonColor

缎带将显示的颜色

marginColor

缎带边缘的颜色

marginWidth

缎带边缘的宽度

originDistance

从容器视图的参考点到缎带的最近点的距离

ribbonLength

缎带的长度,仅适用于 .Left .Right 和 .Top 类型

keepInBounds

如果启用,可以修改起点距离和飘带宽度,以保持飘带在容器边界内

movesHorizontally

如果启用,在需要时将按水平方向移动飘带来保持整个飘带在容器边界内

usesShadow

如果启用,则飘带将投射阴影

displayDecorators

如果启用,它将在飘带的边缘显示装饰项,要使它们可见,应在父视图中禁用clipstobounds

type

它确定飘带在容器中的位置,允许以下值

enum RibbonType {
    case TopLeftCorner
    case TopRightCorner
    case BottomLeftCorner
    case BottomRightCorner
    case Left
    case Right
    case Top
}

autoresizePadding

当启用自动调整大小时,在飘带及其标签之间添加的内边距

autoresizes

启用后,飘带宽度将与标签高度相等

Methods

wrap(view: UIView)

用于使用当前飘带包装一个视图

setDashPattern(lineWidth: CGFloat, spaceWidth: CGFloat)

设置一个虚线图案作为飘带的边距,其中lineWidth将是条纹长度,spaceWidth是条纹之间的长度

License

MIT License

Copyright (c) 2016 Ricard Romeo Murgó (https://github.com/ricardrm88)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.