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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:35:19+00:00 2026-06-15T01:35:19+00:00

I need help with drawing something like this: I have been told that the

  • 0

I need help with drawing something like this:
enter image description here

I have been told that the gray background bar and the purple bar should be drawn on separate layers. And then the dots there that signifies the chapters of a book (which this slider is about) will be on a layer on top of those two.

I have accomplished the task of creating the gradient on the active bar and drawing it like so:

- (void)drawRect:(CGRect)rect{
    self.opaque=NO;

    CGRect viewRect = self.bounds;
    //NSLog(@"innerRect width is: %f", innerRect.size.width);
    CGFloat perPageWidth =  viewRect.size.width/[self.model.book.totalPages floatValue];
    NSLog(@"perpage width is: %f", perPageWidth);
    CGContextRef context = UIGraphicsGetCurrentContext();

    UIBezierPath *beizerPathForSegment= [UIBezierPath bezierPath];

    NSArray *arrayFromReadingSessionsSet =[self.model.readingSessions allObjects];
    NSArray *arrayFromAssesmentSet = [self.model.studentAssessments allObjects];
    NSLog(@"array is : %@", self.model.readingSessions);

    CGGradientRef gradient = [self gradient];



    for (int i=0;i<[arrayFromReadingSessionsSet count]; i++) {

        ReadingSession *tempRSObj= [arrayFromReadingSessionsSet objectAtIndex:i];
        CGFloat pageDifference = [tempRSObj.endPage floatValue]-[tempRSObj.startPage floatValue];
        NSLog(@"startpage is: %@, end page is: %@, total pages are: %@", tempRSObj.startPage, tempRSObj.endPage, self.model.book.totalPages) ;


        CGRect ProgressIndicator = CGRectMake(perPageWidth*[tempRSObj.startPage floatValue], viewRect.origin.y, perPageWidth*pageDifference, viewRect.size.height);


       [beizerPathForSegment appendPath:[UIBezierPath bezierPathWithRoundedRect:ProgressIndicator cornerRadius:13.0]];
}
[beizerPathForSegment addClip];

    CGContextDrawLinearGradient(context, gradient, CGPointMake(CGRectGetMidX([beizerPathForSegment bounds]), CGRectGetMaxY([beizerPathForSegment bounds])),CGPointMake(CGRectGetMidX([beizerPathForSegment bounds]), 0), (CGGradientDrawingOptions)NULL);
}

How do I shift it onto a layer and then create another layer and another layer and then put them over one another?

TIA

  • 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-15T01:35:20+00:00Added an answer on June 15, 2026 at 1:35 am

    I’m guessing the person you spoke with was referring to CALayer. In iOS, every view has a CALayer backing it. Instead of implementing -drawRect: in your view, do this:

    1. link with QuartzCore
    2. #import <QuartzCore/QuartzCore.h> anywhere you want to use this.
    3. Use to your view’s layer property.

    Layers behave a lot like views, in that you can have sublayers and superlayers, and layers have properties for things like background color, and they can be animated. A couple of subclasses that will probably be useful for your purposes are CAGradientLayer and CAShapeLayer. For more on how to use layers, refer to the Core Animation Programming Guide.

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

Sidebar

Related Questions

Need help with a query that I wrote: I have three tables Company id
I need a help on this, There are 3 picture boxes, red should grow
I need the fastest sphere mapping algorithm. Something like Bresenham's line drawing one. Something
I am completely new to opengl and need some help in drawing a texture
I need some drawings in my tableview. How can i do this. Any help
Need help writing a script downloads data from google insight using c# this is
need help/guide for sql select query, I have 2 table stock and stock_history, in
need help regarding USSD Gateway. I have to develop an app, which will directly
This is for a tic tac toe game. I need help making a check
I have been working on projects that deal with 2-Dimensional graphing, UML diagramming and

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.