DDPageControl icon indicating copy to clipboard operation
DDPageControl copied to clipboard

How to limit the width of the page control ?

Open ErwannRobin opened this issue 13 years ago • 1 comments

If i add a lot of pages, the DDPageControl component extend its size beyond the size of the device. I am trying to limit the width of the component, but how can I still show to the user where he is in the scrollview ?

ErwannRobin avatar May 06 '12 17:05 ErwannRobin

I've added a category in my code to do this. This would be good to get it in the official code:

#define CLASSIC_DOTS_BY_SCREEN 20

@implementation DDPageControl (DynamicSize)

// When I have too much memories, I need to display the dots in a smaller way
-(void) updatePageControlSize {
    if (self.numberOfPages > CLASSIC_DOTS_BY_SCREEN) {
        int divide = self.numberOfPages / CLASSIC_DOTS_BY_SCREEN + 1;
        // Change the diameter and space so all dots can enter in the page

        // Note that I use constants because I can't add variables such as originalDiameter and originalSpace to calculate the correct size depending on self.indicatorDiameter and self.indicatorSpace the developper entered
        self.indicatorDiameter = 4.0f / divide;
        self.indicatorSpace = 12.0f / divide;
    }
}

@end

CedricSoubrie avatar Sep 13 '12 14:09 CedricSoubrie