Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8895557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:48:41+00:00 2026-06-14T23:48:41+00:00

I draw the speech bubble using UIBezierpath in a UIView class. In the view

  • 0

I draw the speech bubble using UIBezierpath in a UIView class. In the view class contain the UITextView. I am using the following code to used to draw the speech bubble.

//BezierPathView.h

@interface BezierpathView :  UIView<UITextViewDelegate>{

CGFloat animatedDistance;

UITextView *LXVolabel;
UIView *view;
UIBezierPath* speechBubbleTopPath;
UIBezierPath* rectanglePath;
UIBezierPath* speechBubbleBottomPath;
UIColor* darkGray;
UIColor* shadow;
CGSize shadowOffset;
CGFloat shadowBlurRadius;
NSString* textContent;
}
 @property(nonatomic,strong)UIView *view;
 @property(nonatomic,strong)UITextView *LXVolabel;

//BezierPath.m

@implementation BezierpathView
@synthesize LXVolabel,view;
- (id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
    self.backgroundColor = [UIColor clearColor];
    self.LXVolabel = [[UITextView alloc]initWithFrame:CGRectMake(0, 0,self.frame.size.width , self.frame.size.height-10)];
    self.LXVolabel.backgroundColor = [UIColor clearColor];
    self.LXVolabel.delegate = self;
    self.LXVolabel.font = [UIFont systemFontOfSize:20];

    [self addSubview:self.LXVolabel];

    CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
    view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, applicationFrame.size.width, applicationFrame.size.height)];


    // Color Declarations
    darkGray = [UIColor grayColor];

    // Shadow Declarations
    shadow= [UIColor blackColor];
    shadowOffset= CGSizeMake(0, 1);
    shadowBlurRadius= 1;

    // Abstracted Graphic Attributes
    textContent= LXVolabel.text;

}
return self;
}
 - (void)drawRect:(CGRect)rect
 {
[super drawRect:rect];
  CGContextRef  context = UIGraphicsGetCurrentContext();

   // Drawing code

//// General Declarations

// speechBubbleTop Drawing
speechBubbleTopPath = [UIBezierPath bezierPath];
[speechBubbleTopPath moveToPoint: CGPointMake(294, 7)];
[speechBubbleTopPath addCurveToPoint: CGPointMake(288, -0) controlPoint1: CGPointMake(294, 3.13) controlPoint2: CGPointMake(291.31, -0)];
[speechBubbleTopPath addLineToPoint: CGPointMake(8, -0)];
[speechBubbleTopPath addCurveToPoint: CGPointMake(2, 7) controlPoint1: CGPointMake(4.69, -0) controlPoint2: CGPointMake(2, 3.13)];
[speechBubbleTopPath addLineToPoint: CGPointMake(294, 7)];
[speechBubbleTopPath closePath];
[darkGray setFill];
[speechBubbleTopPath fill];



  // Rectangle Drawing
  rectanglePath = [UIBezierPath bezierPathWithRect: CGRectMake(2, 6, 292,self.frame.size.height-15)];
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
[darkGray setFill];
[rectanglePath fill];
CGContextRestoreGState(context);



// Text Drawing
CGRect textRect = CGRectMake(7, 6, 292, self.frame.size.height-15);
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
[[UIColor whiteColor] setFill];
[textContent drawInRect: textRect withFont: [UIFont fontWithName: @"Helvetica-Light" size: 14] lineBreakMode: NSLineBreakByWordWrapping alignment: NSTextAlignmentLeft];
//CGContextRestoreGState(context);

float addedHeight = 100 -38;

[self drawPath:addedHeight contextValue:context];
//speechBubbleBottom Drawing


speechBubbleBottomPath = [UIBezierPath bezierPath];
[speechBubbleBottomPath moveToPoint: CGPointMake(2, 24+addedHeight)];
[speechBubbleBottomPath addCurveToPoint: CGPointMake(8, 30+addedHeight) controlPoint1: CGPointMake(2, 27.31+addedHeight) controlPoint2: CGPointMake(4.69, 30+addedHeight)];
[speechBubbleBottomPath addLineToPoint: CGPointMake(13, 30+addedHeight)];
[speechBubbleBottomPath addLineToPoint: CGPointMake(8, 42+addedHeight)];
[speechBubbleBottomPath addLineToPoint: CGPointMake(25, 30+addedHeight)];
[speechBubbleBottomPath addLineToPoint: CGPointMake(288, 30+addedHeight)];
[speechBubbleBottomPath addCurveToPoint: CGPointMake(294, 24+addedHeight) controlPoint1: CGPointMake(291.31, 30+addedHeight) controlPoint2: CGPointMake(294, 27.31+addedHeight)];
[speechBubbleBottomPath addLineToPoint: CGPointMake(2, 24+addedHeight)];
[speechBubbleBottomPath closePath];
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
[darkGray setFill];
[speechBubbleBottomPath fill];
CGContextRestoreGState(context);

}
 -(void)textViewDidChange:(UITextView *)textView{
CGRect rect = textView.frame;
rect.size.height = textView.contentSize.height;// Adding.size Since height is not a member of CGRect
  self.frame = CGRectMake(10, 20, textView.frame.size.width, textView.contentSize.height+20);
   textView.frame = rect;
 }

My thought is that when I have entered the text in the text view I want to increase the speech bubble size based on the text of the text view. But my speech bubble size does not increased correctly. How do I solve this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:48:42+00:00Added an answer on June 14, 2026 at 11:48 pm

    Are you triggering the redraw when the text is changed?

    In the textViewDidChange method add…

    [self setNeedsDisplay];
    

    … as the last line.

    This will trigger the drawRect method again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I draw the message bubble using UIBezierpath in uiview. I render the textview inside
I draw a background image in a view with the following code: CGContextRef currentContext
I draw an triangle using these piece of code CGPoint center; center = CGPointMake(x1,
I draw a bitmap onto a canvas using the following call: _playerImage = BitmapFactory.decodeResource(getResources(),
I draw buildings in my game world, i shade them with the following code:
I'm trying to draw image using UIImage 's drawInRect: method. Here is the code:
I draw the text using CTFramesetter, I have set kCTParagraphStyleSpecifierParagraphSpacing , kCTParagraphStyleSpecifierLineSpacing , kCTParagraphStyleSpecifierParagraphSpacingBefore
I draw the ellipse with the code as shown below. How can I make
I draw picture in canvas in place where I click. This is code: public
I draw an arc using onDraw(canvas) : @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.