如何在iPhone中使用核心图形制作思维泡泡
我正在用核心图形制作各种形状的语音泡泡 然而,我不确定如何制造思想泡沫 我用这个长方形做了一个圆形的长方形。我是否使用相同的方法来如何在iPhone中使用核心图形制作思维泡泡,iphone,ios,Iphone,Ios,我正在用核心图形制作各种形状的语音泡泡 然而,我不确定如何制造思想泡沫 我用这个长方形做了一个圆形的长方形。我是否使用相同的方法来 制造一个思维泡泡,或者还有其他方法吗?我认为你可以将此作为初始指导,然后在此基础上继续: 这是桑弗尤1号在那篇文章中的回答 我会在两次迭代中完成。首先获取上下文并开始 路径先填充椭圆,然后填充包围三角形的自定义路径 有三行。我假设以下尺寸:70宽,62 身高在UIView的子类中重写draw rect并在中实例化 子类UIViewController: -(voi
制造一个思维泡泡,或者还有其他方法吗?我认为你可以将此作为初始指导,然后在此基础上继续: 这是桑弗尤1号在那篇文章中的回答 我会在两次迭代中完成。首先获取上下文并开始 路径先填充椭圆,然后填充包围三角形的自定义路径 有三行。我假设以下尺寸:70宽,62 身高在UIView的子类中重写draw rect并在中实例化 子类UIViewController:
-(void)drawRect:(CGRect)rect {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(ctx, 0.0, 0.0, 1.0, 1.0);
CGContextFillEllipseInRect(ctx, CGRectMake(0.0, 0.0, 70.0, 50.0)); //oval shape
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, 8.0, 40.0);
CGContextAddLineToPoint(ctx, 6.0, 50.0);
CGContextAddLineToPoint(ctx, 18.0, 45.0);
CGContextClosePath(ctx);
CGContextFillPath(ctx);
}
当在iPhone模拟器中添加灰色时,会产生此效果
背景:
第二个代码示例几乎与您生成的代码重复
在上面我使用可以提供的灵活尺寸实现了这一点
在实例化UIView框架时将其复制到UIView框架。基本上,白色
演讲泡泡的一部分用黑色笔划画在铺层上
跟着
-(void)drawRect:(CGRect)rect {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGRect aRect = CGRectMake(2.0, 2.0, (self.bounds.size.width * 0.95f), (self.bounds.size.width * 0.60f)); // set the rect with inset.
CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0); //white fill
CGContextSetRGBStrokeColor(ctx, 0.0, 0.0, 0.0, 1.0); //black stroke
CGContextSetLineWidth(ctx, 2.0);
CGContextFillEllipseInRect(ctx, aRect);
CGContextStrokeEllipseInRect(ctx, aRect);
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, (self.bounds.size.width * 0.10), (self.bounds.size.width * 0.48f));
CGContextAddLineToPoint(ctx, 3.0, (self.bounds.size.height *0.80f));
CGContextAddLineToPoint(ctx, 20.0, (self.bounds.size.height *0.70f));
CGContextClosePath(ctx);
CGContextFillPath(ctx);
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, (self.bounds.size.width * 0.10), (self.bounds.size.width * 0.48f));
CGContextAddLineToPoint(ctx, 3.0, (self.bounds.size.height *0.80f));
CGContextStrokePath(ctx);
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, 3.0, (self.bounds.size.height *0.80f));
CGContextAddLineToPoint(ctx, 20.0, (self.bounds.size.height *0.70f));
CGContextStrokePath(ctx);
}
编辑:
你也可以在这篇文章中参考布拉德·拉森的答案
希望这对你有帮助
如果您需要更多帮助,请告诉我。我认为您可以将此作为初始指导,然后在此基础上继续: 这是桑弗尤1号在那篇文章中的回答 我会在两次迭代中完成。首先获取上下文并开始 路径先填充椭圆,然后填充包围三角形的自定义路径 有三行。我假设以下尺寸:70宽,62 身高在UIView的子类中重写draw rect并在中实例化 子类UIViewController:
-(void)drawRect:(CGRect)rect {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(ctx, 0.0, 0.0, 1.0, 1.0);
CGContextFillEllipseInRect(ctx, CGRectMake(0.0, 0.0, 70.0, 50.0)); //oval shape
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, 8.0, 40.0);
CGContextAddLineToPoint(ctx, 6.0, 50.0);
CGContextAddLineToPoint(ctx, 18.0, 45.0);
CGContextClosePath(ctx);
CGContextFillPath(ctx);
}
当在iPhone模拟器中添加灰色时,会产生此效果
背景:
第二个代码示例几乎与您生成的代码重复
在上面我使用可以提供的灵活尺寸实现了这一点
在实例化UIView框架时将其复制到UIView框架。基本上,白色
演讲泡泡的一部分用黑色笔划画在铺层上
跟着
-(void)drawRect:(CGRect)rect {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGRect aRect = CGRectMake(2.0, 2.0, (self.bounds.size.width * 0.95f), (self.bounds.size.width * 0.60f)); // set the rect with inset.
CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0); //white fill
CGContextSetRGBStrokeColor(ctx, 0.0, 0.0, 0.0, 1.0); //black stroke
CGContextSetLineWidth(ctx, 2.0);
CGContextFillEllipseInRect(ctx, aRect);
CGContextStrokeEllipseInRect(ctx, aRect);
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, (self.bounds.size.width * 0.10), (self.bounds.size.width * 0.48f));
CGContextAddLineToPoint(ctx, 3.0, (self.bounds.size.height *0.80f));
CGContextAddLineToPoint(ctx, 20.0, (self.bounds.size.height *0.70f));
CGContextClosePath(ctx);
CGContextFillPath(ctx);
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, (self.bounds.size.width * 0.10), (self.bounds.size.width * 0.48f));
CGContextAddLineToPoint(ctx, 3.0, (self.bounds.size.height *0.80f));
CGContextStrokePath(ctx);
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, 3.0, (self.bounds.size.height *0.80f));
CGContextAddLineToPoint(ctx, 20.0, (self.bounds.size.height *0.70f));
CGContextStrokePath(ctx);
}
编辑:
你也可以在这篇文章中参考布拉德·拉森的答案
希望这对你有帮助
如果您需要更多帮助,请告诉我。um。。我想根据文本的长度来改变spb的大小,但我不知道怎么做..嗯。。我想根据文本的长度改变spb的大小,但我不知道怎么做。。