Coder Social home page Coder Social logo

sliderpagecontrol-for-ios's Introduction

SliderPageControl for iOS

This is an alternative for UIPageControl. See video here

Required Files

  1. SliderPageControl.h
  2. SliderPageControl.m
  3. SliderPageControl.bundle/images/sliderPageControl.png
  4. SliderPageControl.bundle/images/sliderPageControlBg.png

Usage

  1. To integrate SliderPageControl, drag the files above to your XCode Project, and add to your view.

    #import SliderPageControl.h

  2. set number of pages

    • (void)setNumberOfPages:(int)page
  3. returns the current page

    • (int)currentPage
  4. set the current page. set animated=YES to animate the control

    • (void)setCurrentPage:(int)_currentPage animated:(BOOL)animated
  5. set page title that is visible when the control is dragged

    • (NSString *)sliderPageController:(id)controller hintTitleForPage:(NSInteger)page
  6. Skinning SliderPageControl To skin SliderPageControl, use the provided PSD file to change the control image (sliderPageControl.png) and the background (sliderPageControlBg.png)

You can find more information about SliderPageControl at the link below

Requirements

  • ARC
  • XCode 4.4 (auto-synthesis)

Contact

@honcheng
honcheng.com

sliderpagecontrol-for-ios's People

Contributors

honcheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sliderpagecontrol-for-ios's Issues

Changing Slider Background from ellipse to UILabel Text

Hi honcheng,

So your class is AMAZING, it got me passed the issue of being able to PRELOAD all views before the user even starts sliding.

VERY CONVENIENT.

Anyways, I am currently attempting to change the circles in the sliders to text.....

I created UILabels and basically took the example project and tried to implement the modification myself, but am still having issues.

  • (void)drawRect:(CGRect)rect {
    // Drawing code
    //CGContextRef myContext = UIGraphicsGetCurrentContext();
    float diameter = 10;

    CGFloat blackColor[4];
    blackColor[0]=0.0;
    blackColor[1]=0.0;
    blackColor[2]=0.0;
    blackColor[3]=1.0;
    float width = self.frame.size.width/self.numberOfPages;

    UILabel *label = [[UILabel alloc] init];
    label.backgroundColor = [UIColor clearColor];
    [label setFont:[UIFont systemFontOfSize:8]];

    int i;
    for (i=0; i<self.numberOfPages; i++)
    {
    int x = i*width + (width-diameter)/2;

    if (i == 0) {
        label.frame = CGRectMake(x,(self.frame.size.height-diameter)/2,10,10);
        label.text = @"Day";
        [self addSubview:label];
    } else if (i == 1) {
        label.frame = CGRectMake(x,(self.frame.size.height-diameter)/2,diameter,diameter);
        label.text = @"Day";
        [self addSubview:label];
    } else if (i == 2) {
        label.frame = CGRectMake(x,(self.frame.size.height-diameter)/2,diameter,diameter);
        label.text = @"Day";
        [self addSubview:label];
    } else if (i == 3) {
        label.frame = CGRectMake(x,(self.frame.size.height-diameter)/2,diameter,diameter);
        label.text = @"Day";
        [self addSubview:label];
    } else if (i == 4) {
        label.frame = CGRectMake(x,(self.frame.size.height-diameter)/2,diameter,diameter);
        label.text = @"Day";
        [self addSubview:label];
    } else if (i == 5) {
        label.frame = CGRectMake(x,(self.frame.size.height-diameter)/2,20,diameter);
        label.text = @"Day";
        [self addSubview:label];
    } 
    //CGContextSetFillColor(myContext, blackColor);
    //CGContextFillEllipseInRect(myContext, CGRectMake(x,(self.frame.size.height-diameter)/2,diameter,diameter));
    

    }
    }

This is what I modified in the drawRect:int method but all it does is make the label in the LAST spot where the circles are supposed to be.

The first, second, third, forth, and fifth circles vanished - of course, but the last circle is not a black square (the UILabel), why don't I see other black squares in the other sports where the other circles should be?

Also, when I modify the size of the UILabels, nothing changes, the black square is still of the same dimensions, changing the width and height from 10 ->50 does nothing.

Any help would help :P
screen shot 2013-06-20 at 8 37 38 am 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.