- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
/**
QQ聊天 气泡的实现
*/
self.QQBubble = [UIButton buttonWithType:UIButtonTypeCustom];
self.QQBubble.backgroundColor = [UIColor blueColor];
// self.QQBubble.titleLabel.backgroundColor = [UIColor purpleColor];
NSString *string = @"《蛮荒记》的故事展开:大荒586年, 神农化羽,神帝之位悬空,引发金、木、水、火、土五族大战。神农传人拓跋野与义弟蚩尤联合对抗侵略者,双军交锋,大地却在战场中央裂开,封印太古凶魔的皮母地丘重现人间《蛮荒记》的故事展开:大荒586年, 神农化羽,神帝之位悬空,引发金、木、水、火、土五族大战。神农传人拓跋野与义弟蚩尤联合对抗侵略者,双军交锋,大地却在战场中央裂开,封印太古凶魔的皮母地丘重现人间《蛮荒记》的故事展开:大荒586年, 神农化羽,神帝之位悬空,引发金、木、水、火、土五族大战。神农传人拓跋野与义弟蚩尤联合对抗侵略者,双军交锋,大地却在战场中央裂开,封印太古凶魔的皮母地丘重现人间";
[_QQBubble setTitle:string forState:UIControlStateNormal];
[_QQBubble setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
_QQBubble.titleLabel.numberOfLines =0;
_QQBubble.titleLabel.font = MyFont;
/**
*
* -----内容尺寸(高度)根据 字的数量、字体多少决定----- 按钮尺寸需要比内容尺寸宽20边界
*
*/
CGSize textSize = [string boundingRectWithSize:CGSizeMake(150, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:MyFont} context:nil].size;
CGSize textBtnSize = CGSizeMake(textSize.width + Padding*2, textSize.height +Padding*2);
self.QQBubble.contentEdgeInsets = UIEdgeInsetsMake(Padding, Padding, Padding, Padding);
self.QQBubble.frame = CGRectMake(50, 100, textBtnSize.width, textBtnSize.height);
/**
* -----拉伸图片 (防止边框走样)------
*/
UIImage *normal = [UIImage imageNamed:@"yellowfish.png"];
CGFloat w = normal.size.width * 0.5;
CGFloat h = normal.size.height * 0.5;
UIImage *lastImage = [normal resizableImageWithCapInsets:UIEdgeInsetsMake(h-1, w-1, h, w)];
[self.QQBubble setBackgroundImage:lastImage forState:UIControlStateNormal];
[self.view addSubview:self.QQBubble];
}