问题
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