小编Joh*_*son的帖子

UIView.animateWithDuration快速循环动画

在ViewController.Swift中,我设法从一个点到另一个点创建一个框.我认为循环这很容易,所以框会动画到一个点,然后动画回到原来的位置,然后再循环.我已设法将对象移动到一个位置并在"完成"中再次将其移回,但这并不会使我循环.怎么能实现这一目标?

我想也许这可行,但老实说我不知道​​:

let boxmoves = [CGRect(x: 120, y: 220, width: 100, height: 100), CGRect(x: 120, y: 120, width: 100, height: 100)]
for boxmove in boxmoves {
    coloredSquare.frame = boxmove
}
Run Code Online (Sandbox Code Playgroud)

我怎么能根据设备宽度将它居中(我假设涉及一些数学?)?

我的代码:

let coloredSquare = UIView()

coloredSquare.backgroundColor = UIColor.blueColor()

coloredSquare.frame = CGRect(x: 120, y: 120, width: 100, height: 100)

self.view.addSubview(coloredSquare)

// found repeate but this will not animate as I want.
//UIView.animateWithDuration(2.0, delay: 0.2, options: UIViewAnimationOptions.Repeat, animations: {
UIView.animateWithDuration(2.0, animations: {

    coloredSquare.frame = CGRect(x: 120, y: 220, width: 100, height: …
Run Code Online (Sandbox Code Playgroud)

core-animation uikit uiviewanimation ios swift

33
推荐指数
1
解决办法
4万
查看次数

使用检测移动浏览器脚本检测平板电

我正在使用php版本的detectmobilebrowsers.com来检测移动浏览器.

我想在这个脚本中添加平板电脑,并在about页面上提到我应该将以下内容添加到第一个正则表达式:| android | ipad | playbook | silk

我不知道放在哪里?

我还想知道是否有办法只使用此脚本检查平板电脑.这是可能的还是我应该放弃使用上面提到的脚本并为我的目的使用另一个检测脚本?

我已经研究了其他选择:http://code.google.com/p/mobileesp/source/browse/PHP/mdetect.php

和mobiledetect.net

有什么想法吗?什么是最好的解决方案?

亲切的问候约翰

php mobile

3
推荐指数
1
解决办法
4491
查看次数

标签 统计

core-animation ×1

ios ×1

mobile ×1

php ×1

swift ×1

uikit ×1

uiviewanimation ×1