MessengerBubbles
[](https://travis-ci.org/Laurent Grondin/MessengerBubbles)
示例
要运行示例项目,首先克隆仓库,并在示例目录中运行 pod install
。
需求
安装
CocoaPods
可以通过CocoaPods使用MessengerBubbles。要安装它,只需将以下行添加到您的Podfile中
pod 'MessengerBubbles'
手动安装
如果您不想使用上述任何依赖管理器,您可以手动将CodableCloudKit集成到项目中。只需将“Source”文件夹拖动到Xcode项目中即可。
用法
从Storyboard中
MessengerBubbles是UIView的子视图
只需创建一个UIView
,然后用MessengerBubbles
替换自定义类
可以选择是否启用在线泡泡指示器,以及用户或组是否在线,更改在线泡泡颜色和边框颜色。
程序化
有多种方式可以创建MessengerBubbles
public init(size: CGFloat,
borderColor: UIColor = .white,
onlineBubbleColor: UIColor = PrivateConstants.onlineBubbleColor,
enableOnlineBubble: Bool = true,
isOnline: Bool = false)
public init(images: [UIImage?]?,
size: CGFloat,
borderColor: UIColor = .white,
onlineBubbleColor: UIColor = PrivateConstants.onlineBubbleColor,
enableOnlineBubble: Bool = true,
isOnline: Bool = false)
public init(urls: [String?]?,
size: CGFloat,
borderColor: UIColor = .white,
onlineBubbleColor: UIColor = PrivateConstants.onlineBubbleColor,
enableOnlineBubble: Bool = true,
isOnline: Bool = false)
大小始终是必需的。其他所有属性都有默认值。
MessengerBubbles(size: 60) // With size only
MessengerBubbles(size: 60, borderColor: .blue,
onlineBubbleColor: .yellow,
enabledOnlineBubble: false,
isOnline: false) // With custom values
MessengerBubbles(images: images,
size: 60) // With an array of UIImage at initialization
MessengerBubbles(urls: urls,
size: 60) // With an array of String at initialization
创建MessengerBubbles
后可以设置图片。如果您的数组中只有一个元素,它将创建一个泡泡。顺便说一句,如果它包含2个或更多元素,即使包含超过2个元素,它也会创建2个泡泡。
public func setImages(with images: [UIImage?]?) // Set images with an array of UIImage
public func setImages(with urls: [String?]?) // Set images with an array of String
let bubble = MessengerBubbles(size: 60)
bubble.setImages(with: images)
//or
bubble.setImages(with: urls)
isOnline
和onlineBubbleColor
可以在初始化后更改
bubble.isOnline = true // or false
bubble.onlineBubbleColor = .black // or whatever you want
作者
Laurent Grondin, [email protected]
贡献者
非常欢迎贡献
许可证
MessengerBubbles 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。