#pragma mark-Adaptive for chat bubbles
-(void) bubblestocalculate{
CGRect rect = [_field.text boundingrectwithsize:cgsizemake (maxfloat) options: nsstringdrawinguseslinefragmentorigin| Nsstringdrawingusesfontleading attributes:@{nsfontattributename: [Uifont systemfontofsize:15]} Context:Nil];
Cgsize size = rect.size;
UIView *view = [[UIView alloc] Initwithframe:cgrectmake (screen_width-size.width-15, 5, size.width+15, size.height+15)] ;
Uiimageview *imageview = [[Uiimageview alloc] Initwithframe:cgrectmake (0, 0, size.width+15, size.height+15)];
UIImage *bgimg = [UIImage imagenamed:@ "bubbleself"];
UIImage *image = [bgimg stretchableimagewithleftcapwidth:10 topcapheight:10];
Imageview.image = image;
[View Addsubview:imageview];
UILabel *lab = [[UILabel alloc] Initwithframe:cgrectmake (5, 2, Size.width, size.height+5)];
Lab.font = [Uifont systemfontofsize:15];
Lab.numberoflines = 0;
Lab.text =_field.text;
View.tag = 10;
[View Addsubview:lab];
[_messagearray Addobject:view];
[_bgview Reloaddata];
_field.text = @ "";
Nsindexpath *indexpath = [Nsindexpath indexpathforrow:_messagearray.count-1 insection:0];
[_bgview Scrolltorowatindexpath:indexpath Atscrollposition:uitableviewscrollpositionbottom Animated:YES];
[_field Resignfirstresponder];
[UIView animatewithduration:0.34 animations:^{
_inputview.frame = CGRectMake (0, self.view.frame.size.height-60, Screen_width, 40);
}];
[Lab release];
[View release];
[ImageView release];
}
Simple Chat Drum Adaptive