MMBubbleView 1.0

MMBubbleView 1.0

Maintained by LEA.



  • By
  • Chelly Lau

MMBubbleView

Support  CocoaPods  CocoaPods  License MIT 

MMBubbleView

使用CoreGraphics框架实现气泡绘制,支持各个方向的箭头。可用于聊天气泡、弹框气泡等,视觉效果详见截图。

CocoaPods

  1. pod "MMBubbleView";
  2. pod install / pod update;
  3. #import <MMBubbleView.h>.

属性

枚举:

typedef NS_ENUM(NSInteger, MMBubbleType) {
    MMBubbleTypeTopLeft = 0,    // 箭头顶部左边
    MMBubbleTypeTopMiddle,      // 箭头顶部中间
    MMBubbleTypeTopRight,       // 箭头顶部右边
    MMBubbleTypeLeftTop,        // 箭头左边顶部
    MMBubbleTypeLeftMiddle,     // 箭头左边中间
    MMBubbleTypeLeftBottom,     // 箭头左边底部
    MMBubbleTypeBottomLeft,     // 箭头底部左边
    MMBubbleTypeBottomMiddle,   // 箭头底部中间
    MMBubbleTypeBottomRight,    // 箭头底部右边
    MMBubbleTypeRightTop,       // 箭头右边顶部
    MMBubbleTypeRightMiddle,    // 箭头右边中间
    MMBubbleTypeRightBottom,    // 箭头右边底部
};

属性:

// 气泡类型
@property(nonatomic, assign) MMBubbleType bubbleType;
// 边距(箭头处于中间时,该字段无用)
@property(nonatomic, assign) CGFloat margin;
// 箭头高度
@property(nonatomic, assign) CGFloat arrowHeight;
// 箭头宽度
@property(nonatomic, assign) CGFloat arrowWidth;
// 圆角半径
@property(nonatomic, assign) CGFloat cornerRadius;
// 边线宽度
@property(nonatomic, assign) CGFloat lineWidth;
// 边线颜色
@property(nonatomic, strong) UIColor * strokeColor;
// 填充颜色
@property(nonatomic, strong) UIColor * fillColor;

示例

MMBubbleView * bubbleView = [[MMBubbleView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
bubbleView.fillColor = [UIColor whiteColor];
bubbleView.bubbleType = MMBubbleTypeTopMiddle;
[self.view addSubview:bubbleView];

后记

不定时更新,如有问题欢迎给我留言,我会及时回复。如果这个工具对你有一些帮助,请给我一个star,谢谢。