Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS Swift-从右到左自动滚动UILabel_Ios_Swift_Uilabel - Fatal编程技术网

iOS Swift-从右到左自动滚动UILabel

iOS Swift-从右到左自动滚动UILabel,ios,swift,uilabel,Ios,Swift,Uilabel,这两列需要自动滚动(如选框)。但我做这件事有困难。我找到了两种解决方案,但不幸的是,它们都不起作用 非常感谢您的帮助 试试这个: let label = UILabel() override func viewDidLoad() { super.viewDidLoad() label.frame = CGRectMake(320, 100, 200, 60) label.text = "This is my music line" self.view

这两列需要自动滚动(如选框)。但我做这件事有困难。我找到了两种解决方案,但不幸的是,它们都不起作用

  • 非常感谢您的帮助

    试试这个:

        let label = UILabel()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        label.frame = CGRectMake(320, 100, 200, 60)
        label.text = "This is my music line"
        self.view!.addSubview(label)
        NSTimer.scheduledTimerWithTimeInterval(2.0, target: self, selector: #selector(self.LabelAnimate), userInfo: nil, repeats: true)
    }
    
    func LabelAnimate() {
        UIView.animateWithDuration(3.0, delay: 0.0, options: .TransitionNone, animations: {() -> Void in
        self.label.frame = CGRectMake(-320, 100, 200, 60)
            }, completion: {(isDone: Bool) -> Void in
                self.label.frame = CGRectMake(320, 100, 200, 60)
        })
    }
    }