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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:09:49+00:00 2026-05-29T08:09:49+00:00

I have been trying desperately to draw some images into a view. The view

  • 0

I have been trying desperately to draw some images into a view. The view should be inside a scrollview. For that I subclassed UIScrollview and override the drawRect method in it. And added this as my UIView’s subview.

@interface DrawAnotherViewClass : UIScrollView<UIScrollViewDelegate> {

}
@end



@implementation DrawAnotherViewClass

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

    CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame];
    self.frame = fullScreenRect;
    self.contentSize = CGSizeMake(600, 600);
    self.showsHorizontalScrollIndicator = YES;
    self.showsVerticalScrollIndicator = NO;
    self.pagingEnabled = YES;

}
return self;
}



- (void)drawRect:(CGRect)rect
{
// Drawing code

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0); 
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); 
CGContextMoveToPoint(context, 10.0f, 50.0f); 
CGContextAddLineToPoint(context, 10.0f, 200.0f);
CGContextStrokePath(context);

CGContextMoveToPoint(context, 8.0f, 77.0f); 
CGContextAddLineToPoint(context, 300.0f, 77.0f);
CGContextStrokePath(context);

CGContextSetRGBFillColor(context, 0, 0, 255, 0.1);
CGContextSetRGBStrokeColor(context, 0, 0, 255, 1);
CGContextStrokeEllipseInRect(context, CGRectMake(65.0, 33.5, 25, 25));

UIImage *image1 = [UIImage imageNamed:@"PinDown1.png"];
UIImage *image2 = [UIImage imageNamed:@"pinGreen_v1.png"];

CGPoint drawPoint = CGPointMake(0.0f, 10.0f); 
[image2 drawAtPoint:drawPoint];

for(int i =1; i<20; i++){
    CGPoint drawPointOne = CGPointMake(40.0f * i, 40.0f); 
    [image1 drawAtPoint:drawPointOne];
}
}

Am I missing something here. Is this the right way to go.

  • 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-29T08:09:50+00:00Added an answer on May 29, 2026 at 8:09 am

    If the view that should perform the drawing resides in that UIScrollView, you have to put the - (void)drawRect:(CGRect)rect method into that view’s class method and not into the UIScrollView subclass.

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

Sidebar

Related Questions

Have been trying to encrypt an xml file to a string so that I
I have been trying to setup git for our web development team unsuccessfully. Some
I have been trying to serialize a list that contains arrays and lists. I
I have been trying desperately to fix this issue where my ListView items are
I have been trying to find some good sources on how to handle application-wide
I have been trying out some different ways to organize my code in my
I have been trying to do a little project that needs an appendable ObjectOutputStream.
I have been trying to apply one white space inside the span element, but
i have been trying to implement SSO using SAML in Java. for quite some
Have have been trying to make a validator for my xml files. I have

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.