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 7663441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:03:44+00:00 2026-05-31T14:03:44+00:00

I know how to draw lines/rect in a single view. But I’m lost in

  • 0

I know how to draw lines/rect in a single view. But I’m lost in this case:
I have a UIView A and a UITableView B. A is added to a viewController’s view, and B is added to A. As You know, UITableView had no border and hence I try to draw line along the bounds of the B.
Below is the code how I organize these views:


if (_tableView) {
        [_tableView release];
        _tableView = nil;
    }


    UITableView * temp = [[UITableView alloc] initWithFrame:tableRect style:UITableViewStylePlain];
    temp.delegate = self;
    temp.dataSource = self;
    temp.showsHorizontalScrollIndicator = NO;
    temp.alwaysBounceHorizontal = NO;

    self.table = temp;
    [temp release];
    temp = nil;
    [self.table setContentInset:UIEdgeInsetsMake(1, 2, 0, 2)];

    [_transparencyView addSubview:self.table];


    [self.parentViewController.view addSubview:_transparencyView];
    [_transparencyView setNeedsDisplayInRect:tableRect];

The _transparencyView is an instance of ZJTransparencyView inherited from UIView, and its implement file is like:


- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    NSLog(@"%s:%@",__func__,NSStringFromCGRect(rect));

    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetStrokeColorWithColor(context, [UIColor cyanColor].CGColor);
    CGContextSetLineWidth(context, 2);
    CGContextStrokeRect(context, rect);



}

The problem I met is :
When I add the tableview and call setNeedsDisplayInRect:, the rect send to drawRect: is always {0,0,320,460}. It seems that tableRect has no effect. I don’t know why it happens.
Could anyone help me?

  • 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-31T14:03:45+00:00Added an answer on May 31, 2026 at 2:03 pm

    Since tableRect is what you initialize the table, you should have control over it. If you think that the correct rectangle is not refreshed, call setNeedsDisplay without specifying rectangle. But, there really is no need to do custom drawing for this since UITableView inherits from UIView and you can draw a border around UIView.

    Import QuartzCore

    #import <QuartzCore/QuartzCore.h>
    

    and set the border for the UITableView as,

    temp.layer.borderColor=[UIColor cyanColor].CGColor;
    temp.layer.borderWidth=2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

does someone know how to draw 3D surfaces and hide the invisible lines? I
I have data from *.obj file. I know how draw with GL_TRIANGLES . How
Know this might be rather basic, but I been trying to figure out how
I know this is fairly subjective, but I'm diving into testing and learning about
I have been learning MFC these days.I want to draw lines with MoveTo() and
I want to draw as well as redraw some lines from view into my
I have been using RenderTargetBitmap to draw lines for my application as shown here
is there an easy way to not draw this points in my lines? I
I have made a program that allows users to draw lines onto a picturebox
I'm trying to draw semi-transparent primitives (lines, circles) in OpenGL ES using Cocos2d but

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.