本文介绍了Three20中的TTSpeechBubbleShape只绘制“语音”三角形顶部和底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我使用iPhone应用程序的Three20库,并希望使用TTSpeechBubbleShape样式来查看视图。但三角形似乎不想在左侧或右侧绘制。我在源文件中看到,它有很多几何图形,并且想知道是否有人解决了这个问题,或者知道如何解决这个问题。 解决方案

我查看了源代码并填充了缺少的逻辑,以便为讲话泡泡的左侧和右侧绘制边缘。

您可以找到代码。

addRightEdge 的更改:

  if(_pointLocation> 135&& _pointLocation< 225){
CGFloat pw = _pointAngle> = 90&& _pointAngle< 270? _pointSize.width:-_pointSize.width;
CGFloat pointY =((_pointLocation-135)/ 90)* fh;
CGPathAddLineToPoint(path,nil,fw,pointY-floor(_pointSize.height / 2));
CGPathAddLineToPoint(path,nil,fw + pw,pointY);
CGPathAddLineToPoint(path,nil,fw,pointY + floor(_pointSize.height / 2));
}

addLeftEdge 的更改:

$ ((_pointLocation>&&&& _pointLocation< = 360)
||(_pointLocation> = 0& & _pointLocation< 45)){
CGFloat pw =((_pointAngle> = 270&& _pointAngle< = 360)
||(_pointAngle> = 0&& _pointAngle < = 90))
? _pointSize.width
:-_pointSize.width;
CGFloat pointY =(_pointLocation> 315&& _pointLocation< = 360)
? fh - (((_ pointLocation-315)/ 90)* fh)
:(fh / 2) - ((_ pointLocation / 90)* fh);
CGPathAddLineToPoint(path,nil,0,pointY + floor(_pointSize.height / 2));
CGPathAddLineToPoint(path,nil,-pw,pointY);
CGPathAddLineToPoint(path,nil,0,pointY-floor(_pointSize.height / 2));
}


So I am using the Three20 library for an iPhone app, and want to use the TTSpeechBubbleShape style for a view. But the triangle doesn't seem to want to draw on the left or right sides. I see in the source that it's a lot of geometry and was wondering if anyone had tackled this or knew how to fix it.

解决方案

I looked at the source and filled in the missing logic to draw the edge for the left and right side of the speech bubble.

You can find the code here.

Changes to addRightEdge:

if (_pointLocation > 135 && _pointLocation < 225) {
  CGFloat pw = _pointAngle >= 90 && _pointAngle < 270 ? _pointSize.width : -_pointSize.width;
  CGFloat pointY = ((_pointLocation-135)/90)*fh;
  CGPathAddLineToPoint(path, nil, fw, pointY-floor(_pointSize.height/2));
  CGPathAddLineToPoint(path, nil, fw+pw, pointY);
  CGPathAddLineToPoint(path, nil, fw, pointY+floor(_pointSize.height/2));
}

Changes to addLeftEdge:

if ((_pointLocation > 315 && _pointLocation <= 360)
    || (_pointLocation >= 0 && _pointLocation < 45)) {
  CGFloat pw = ((_pointAngle >= 270 && _pointAngle <= 360)
                || (_pointAngle >= 0 && _pointAngle <= 90))
    ? _pointSize.width
    : -_pointSize.width;
  CGFloat pointY = (_pointLocation > 315 && _pointLocation <= 360)
    ? fh-(((_pointLocation-315)/90)*fh)
    : (fh/2)-((_pointLocation/90)*fh);
  CGPathAddLineToPoint(path, nil, 0, pointY+floor(_pointSize.height/2));
  CGPathAddLineToPoint(path, nil, -pw, pointY);
  CGPathAddLineToPoint(path, nil, 0, pointY-floor(_pointSize.height/2));
}

这篇关于Three20中的TTSpeechBubbleShape只绘制“语音”三角形顶部和底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 07:33