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.
Asked
Active
Viewed 627 times
2 Answers
1
You might be looking for TTRoundedLeftArrowShape
and TTRoundedRightArrowShape
, which would look like a standard Back iPhone button.

leolobato
- 2,359
- 3
- 32
- 51
1
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));
}

David H
- 2,901
- 1
- 26
- 21
-
The asker should mark this answer as correct. Beautiful and simple to drop in. I'm using Three20 1.0.5 (the latest to date), and this code is missing form it, although I hope you submitted a pull request. Cheers! And thanks for the fix! – Brett Jun 24 '11 at 12:16