privatefuncaddGesture() { let left =UISwipeGestureRecognizer(target: self, action: #selector(self.swipGesterHandelr(_:))) left.direction = .Left self.imageView.addGestureRecognizer(left) let right =UISwipeGestureRecognizer(target: self, action: #selector(self.swipGesterHandelr(_:))) right.direction = .Right self.imageView.addGestureRecognizer(right) let tap =UITapGestureRecognizer(target: self, action: #selector(self.tapGesterHandelr(_:))) self.imageView.addGestureRecognizer(tap) }
privatefuncscrollWithDirection(direction: ScrollDirection) { switch direction { case .Left: index +=1 if index > imageCounts -1 { index =0 } case .Right: index -=1 if index <0 { index = imageCounts -1 } } if images.count >0 { self.imageView.image = images[index] } else { iflet url =NSURL(string: imageURLStringGroup[index]) { self.imageView.hu_setImageWithURL(url, placeholderImage: placeholderImage) } } addScrollAnimationWithDirection(direction) }
privatefuncaddScrollAnimationWithDirection(direction: ScrollDirection) { let animation =CATransition() animation.duration =0.4 animation.type = kCATransitionPush switch direction { case .Left: animation.subtype = kCATransitionFromRight case .Right: animation.subtype = kCATransitionFromLeft } self.imageView.layer.addAnimation(animation, forKey:"scroll") self.pageControl.currentPage = index }