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

  • Home
  • SEARCH
  • 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 7604309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:52:39+00:00 2026-05-30T23:52:39+00:00

I write a msg background in tableviewcell, but when scrolling, the view become different.

  • 0

I write a msg background in tableviewcell, but when scrolling, the view become different. seems like the “context” store some state.
The code draw a round rect with a arrow.The arrow size should be fixed,but in fact it will change sometimes then scrolling.

 - (void)drawRect:(CGRect)rect
{
    // Drawing code
    CGContextRef context = UIGraphicsGetCurrentContext();

    CGFloat width = self.frame.size.width;
    CGFloat height = self.frame.size.height;


    CGFloat arrowHeight = 10;
    CGFloat arrowWidth = 5;
    CGFloat arrowOffset = 5; 
    CGFloat radius = 5;
    CGFloat shadowHeight = 2;
    CGFloat shadowOffset = 4;

    CGColorRef shadowColor = [UIColor colorWithRed:0.2f
                                             green:0.2f
                                              blue:0.2f
                                             alpha:0.5f].CGColor;

    CGColorRef color;
        color = [UIColor whiteColor].CGColor;

    CGContextSaveGState(context);

        CGContextMoveToPoint(context, width/2, 0);
        CGContextAddArcToPoint(context, width - arrowWidth, 0, width - arrowWidth, height - shadowOffset, radius);
        CGContextAddLineToPoint(context, width - arrowWidth, arrowOffset);
        CGContextAddLineToPoint(context, width, arrowOffset + arrowHeight/2);
        CGContextAddLineToPoint(context, width - arrowWidth, arrowOffset + arrowHeight);
        CGContextAddArcToPoint(context, width - arrowWidth, height - shadowOffset, shadowOffset, height - shadowOffset, radius);
        CGContextAddArcToPoint(context, shadowOffset, height - shadowOffset, shadowOffset, 0, radius);
        CGContextAddArcToPoint(context, shadowOffset, 0, width, 0, radius);

    CGContextSetShadowWithColor(context, CGSizeMake(0, shadowHeight), 3.0, shadowColor);
    CGContextSetFillColorWithColor(context, color);
    CGContextFillPath(context);

    CGContextRestoreGState(context);
}

the effect like this:
enter image description here

  • 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-05-30T23:52:40+00:00Added an answer on May 30, 2026 at 11:52 pm

    I find the problem. the view should redraw when cell is reused,or the view will use the view in last cell to show.

    so, just call [theView setNeedsDisplay] to let the view call drawRect again.

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

Sidebar

Related Questions

I'm overriding WndProc, so I want to write code like if (m.Msg == WM_COMMAND)
I am trying to write a command but I do not want one long
I am getting this error: Msg 201, Level 16, State 4, Procedure NewEmployee, Line
I'm new to C# (from a native C++ background) and I'm trying to write
Issue: When executing @somegeog.STWithin(@othergeog) I get the execption: Msg 6506, Level 16, State 10,
Write a class ListNode which has the following properties: int value; ListNode *next; Provide
Write code to determine if a number is divisible by 3. The input to
Write a program to determine whether a computer is big-endian or little-endian. bool endianness()
You write a function and, looking at the resulting assembly, you see it can
I write my app in VS 2008 and so use all the fanciful stuffs

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.