我有一个标签和一个图像视图。我的目标是在标签前面有 3 个动画点,并在最后位于标签底部,如下所示
我只能在 12promax 上实现这种点移动良好的设计,但是我不知道如何使这种设计始终在不同的手机屏幕尺寸上按预期工作。我该如何编码,以便无论屏幕大小或 uilabel fontsize 都会达到相同的结果?
动画 ImageView(3 点)
func showAnimatingDotsInImageView(dots: UIImageView)
{
let newX = view.bounds.width / 896 * 20
let lay = CAReplicatorLayer()
lay.frame = CGRect(x: newX,y: 0,width: dots.bounds.width,height: dots.bounds.height)
let bar = CALayer()
bar.frame = CGRect(x: 0,y: (dots.bounds.height/2) + 8 ,width: 8,height: 8) //make the objs smaller or bigger
bar.cornerRadius = bar.frame.width / 2 //make a circle, if you uncomment this you will get rects
bar.backgroundColor = UIColor.black.cgColor //colour of the objs
lay.addSublayer(bar)
lay.instanceCount …Run Code Online (Sandbox Code Playgroud)