UIButton下面添加滑动的线

1.循环创建完5个按钮,然后在按钮的线面添加横线。

2.在按钮的点击事件中实现横线滑动的frame的改变

3.代码如下:

[UIView animateWithDuration:.35 animations:^{

        

        CGFloat centerX = button.center.x;

        CGPoint point = CGPointMake(centerX, _selectedLine.center.y);

        _selectedLine.center = point;

        

        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

        

    } completion:^(BOOL finished) {

        

    }];

1
原文地址:https://www.cnblogs.com/fantasy3588/p/4741649.html