开发者

Designing Ichat balloon interface

I am t开发者_如何学Pythonrying for chat balloon kind of interface on iphone, I am able to draw a rounded rect thing and also am able to draw the gradients. But not getting how to achieve gradient drawing in rounded rect.I'll be thankful for any help..


First you need to work out the size of the text to fit in the area

CGSize size = [string sizeWithFont:[UIFont systemFontOfSize:14]
                     constrainedToSize:CGSizeMake(300, 900)
                         lineBreakMode:UILineBreakModeWordWrap];

Draw the text in that size

- (void)drawRect:(CGRect)rect {

    [self.text drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeWordWrap|UILineBreakModeTailTruncation alignment:UITextAlignmentLeft];

}

I used a stretchable UIImage to fit behind the text

UIImage *myImage = [[UIImage imageNamed:@"balloon.png"]  stretchableImageWithLeftCapWidth:23 topCapHeight:13];

Popped it in a UIImageView and set the frame to the be the same size as the text plus a bit of padding.

Hope this helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜