Swift?????????Ч??
???????????? ???????[ 2016/12/27 10:10:49 ] ??????????????????? .NET
???????Ч??: ???????????????????????? ??????????????????λ??????????λ??
????1: ???????????
????for _ in 0...49 {
????let cardSet = UIImageView(image: UIImage(named: "cardBackLandscape"))
????self.view.addSubview(cardSet)
????cardSet.frame = self.landscapeCardBack.frame
????self.cardSetList.append(cardSet)
????}
????NSNotificationCenter.defaultCenter().postNotificationName("setCreated"?? object: nil)
????????????????UIImageView???????????????????Щ????в??? ????????????????? ????λ???????????? ????????????setCreated??? ???????????????card set?????????? ????????е????????
????2: ??????????????????????????????????????????????????ζ?????50????????3????????????
?????????delayTime???????????????? ??????????????????
????????????????±??card???????????????????????????????????UIView????????????????????????????????????????????????????????????????????????????????UIViewAnimation????card????????????????POP?????????????????????Basic????.??????????????????????????????????λ?????delayTime????????????????????shuffleFinished????????????????????????????? ????????????????????
????func shuffleTheSet() {
????self.shuffleButton.userInteractionEnabled = false
????let delayTime = dispatch_time(DISPATCH_TIME_NOW?? Int64(0.5 * Double(NSEC_PER_SEC)))
????dispatch_after(delayTime?? dispatch_get_main_queue()) {
????NSNotificationCenter.defaultCenter().postNotificationName("shuffleFinished"?? object: nil)
????}
????for count in 0...49 {
????UIView.animateWithDuration(0.3?? animations: {
????let cardRotateAnimation = POPBasicAnimation(propertyNamed: kPOPLayerRotation)
????cardRotateAnimation.fromValue = 0
????cardRotateAnimation.toValue = CGFloat(M_PI * 2.0)
????cardRotateAnimation.duration = 1
????// cardRotateAnimation.duration = Double(count>5 ? count/2 : count/10)
????cardRotateAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
????self.cardSetList[count].layer.pop_addAnimation(cardRotateAnimation?? forKey: "cardRotation")
????self.cardSetList[count].frame.origin = CGPointMake(CGFloat(arc4random()) % (250 - 0 + 1) + 0?? CGFloat(arc4random()) % (300 - 74 + 1) + 74)
????self.view.layoutIfNeeded()
????self.landscapeCardBack.removeFromSuperview()
????})
????}
????}
????3: ???????????????λ???????button??title???????????.
????for count in 0...49 {
????UIView.animateWithDuration(0.3?? animations: {
????self.cardSetList[count].center = self.landscapeCardBack.center
????})
????self.view.layoutIfNeeded()
????}
????self.shuffleButton.userInteractionEnabled = true
????self.shuffleButton.setTitle("Cut Card"?? forState: .Normal)
??????
![](/images/ad-banner/ad-banner.png)
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11