TTSpeechBubbleShape in Three20 only draws “speech” triangles top and bottom

无人久伴 提交于 2019-12-07 12:29:46

问题


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.


回答1:


You might be looking for TTRoundedLeftArrowShape and TTRoundedRightArrowShape, which would look like a standard Back iPhone button.




回答2:


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));
}


来源:https://stackoverflow.com/questions/2564583/ttspeechbubbleshape-in-three20-only-draws-speech-triangles-top-and-bottom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!