Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a custom UIScrollView Scroller

Okay, I have been all over the internet trying to find the answer to this, I am trying to create a custom UIScrollView scroller.

Here is a link to a picture of the scroller

http://postimage.org/image/cg2jvde9z/

http://postimage.org/image/ko0mp3kdj/ (that white box is just for me to test the scrollview)

I have gotten the scroller to work, although I need help figuring out how many pixels the scrollview should move every time the scroller is pushed

here is some code

-(IBAction)scroller_bar:(id)sender withEvent:(UIEvent *)event{    
UIButton *button_sent = (UIButton *)sender;

UITouch *touch = [[event touchesForView:button_sent] anyObject];

CGPoint previousLocation = [touch previousLocationInView:button_sent];
CGPoint location = [touch locationInView:button_sent];
CGFloat delta_x = location.x - previousLocation.x;
float left_side = button_sent.center.x + delta_x;
float right_side = button_sent.center.x + delta_x;
if (right_side > button_sent.center.x) {
    scroll_right = YES;
}
else{
    scroll_right = NO;
}
if (left_side <= 13 + 50.5 || right_side >= 307 - 50.5) {

}
else{
    button_sent.center = CGPointMake(button_sent.center.x + delta_x,
                                     button_sent.center.y);

    if (scroll_right) {

    [selection_scroll setContentOffset:CGPointMake(selection_scroll.contentOffset.x - (Help HERE!), selection_scroll.contentOffset.y) animated:YES];
    }
    else{

        [selection_scroll setContentOffset:CGPointMake(selection_scroll.contentOffset.x + (Help HERE!), selection_scroll.contentOffset.y) animated:YES];


    }
}

}

In the above code you should see a '(Help HERE!)',

that is where i am trying to figure out how many pixels i should move the scroll view. This is a bit of a confusing question, hope you understand.

Thanks :)

like image 306
Jacob Avatar asked Dec 06 '25 10:12

Jacob


1 Answers

I don't know whether APPLE will approve this or not but the code written below can change the scollView 's scroller images

for (UIImageView *img in yourscrollView.subviews) { 
    [img setImage:[UIImage imageNamed:@"your custom scroller image"]];
}
like image 191
Piyush Kashyap Avatar answered Dec 07 '25 23:12

Piyush Kashyap



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!