气泡状view

//-(CGPathRef)createPathWithArrowDirection:(MessageViewArrowDirection)direction AndRelativeOrigin:(CGPoint)reletiveOrigin
-(CGPathRef)createPath
{

CGMutablePathRef path = CGPathCreateMutable();
CGRect rect=CGRectInset(self.bounds, 10, 20);
CGFloat minx = CGRectGetMinX(rect), midx = CGRectGetMidX(rect), maxx = CGRectGetMaxX(rect);
CGFloat miny = CGRectGetMinY(rect), midy = CGRectGetMidY(rect), maxy = CGRectGetMaxY(rect);
CGFloat radius=10.0;
CGPathMoveToPoint(path, NULL, minx, midy);
CGPathAddArcToPoint(path, NULL, minx, miny, midx, miny, radius);
CGPathAddLineToPoint(path, NULL, midx-10, miny);
CGPathAddLineToPoint(path, NULL, midx+ARROW_WIDTH/2.0+10, 0);
CGPathAddLineToPoint(path, NULL, midx+ARROW_WIDTH, miny);
CGPathAddArcToPoint(path, NULL, maxx, miny, maxx, midy, radius);
CGPathAddArcToPoint(path, NULL, maxx, maxy, midx, maxy, radius);
CGPathAddArcToPoint(path, NULL, minx, maxy, minx, midy, radius);
CGPathCloseSubpath(path);
return path;
}
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
//inner color
CGFloat R=0.0,G=0.0,B=0.0,A= 0.0;
CGColorRef color = _innerColor.CGColor;
int numComponents = CGColorGetNumberOfComponents(color);
if (numComponents==4)
{
const CGFloat *components = CGColorGetComponents(color);
R = components[0];
G = components[1];
B = components[2];
A = components[3];
}
CGContextRef context=UIGraphicsGetCurrentContext();
CGContextAddPath(context, [self createPath]);
CGContextSetRGBFillColor(context, R, G, B, A);
CGContextFillPath(context);

//outer color
CGContextBeginPath(context);
color = _outerColor.CGColor;
numComponents = CGColorGetNumberOfComponents(color);
if (numComponents==4)
{
const CGFloat *components = CGColorGetComponents(color);
R = components[0];
G = components[1];
B = components[2];
A = components[3];
}
context=UIGraphicsGetCurrentContext();
CGContextAddPath(context, [self createPath]);
CGContextSetRGBStrokeColor(context, R, G, B, A);
CGContextSetLineWidth(context, _outerWidth);
CGContextStrokePath(context);

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值