Shiney Chaudhary Shiney Chaudhary - 6 months ago 13
iOS Question

Change the color of button in the center of uiscrollview

I have a horizontal

UIScrollView
with 100
UIButton
. I want is to change the color of the buttons coming at the
center
of the scrollview?

Answer

I used LTInfiniteScrollview got its code from Github

-(void)updateView:(UIView *)view withProgress:(CGFloat)progress scrollDirection:(ScrollDirection)direction{


//CATransform3D transform = CATransform3DIdentity;

// scale
// CGFloat size = self.viewSize;
CGPoint center = view.center;
view.center = center;
//size = size * (1.4 - 0.3 * (fabs(progress)));
view.frame = CGRectMake(0, 0, 62 , 62);
view.layer.cornerRadius = 62 / 2;
view.center = center;
if (fabs(progress) <= 0.5)
{

    selectedBtn=(UIButton *)view;
    selectedBtn.backgroundColor=[UIColor orangeColor];
    NSString *title =[NSString stringWithFormat:@"%@",selectedBtn.titleLabel.text];
    [dynamicBtn setTitle:title forState:UIControlStateNormal];
    dynamicBtn.titleLabel.textAlignment=NSTextAlignmentCenter;
    dynamicBtn.titleLabel.numberOfLines=2;
    dynamicBtn.titleLabel.textColor=[UIColor whiteColor];

}

else
{
    selectedBtn=(UIButton *)view;
    //selectedBtn.titleLabel.text=[NSString stringWithFormat:@"%d", (int)view.tag];
    selectedBtn.backgroundColor=COLOR;

    }}

selectedBtn is the button at the center of scrollview. If anybody having problem understanding LTInfiniteScrollview can ask me right away.