###Statement
I studied from an open-sourced code whose name is also "PhotoStackView". But I can't find it now. It is written by Objective-C. Here I rewrite it with swift and fix some small bugs. Also I add some function on it.
###Usage
Just like UITableViewDelegate, you can init PhotoStackView and set the delegate and dataSource of it. Then you must implement the dataSource method func numberOfPhotosInStackView(stackView: PhotoStackView) -> Int and func stackView(stackView: PhotoStackView, imageAtIndex index: Int) -> UIImage to provide data for this view. Alternatively, you can implement optional func stackView(stackView: PhotoStackView, sizeOfPhotoAtIndex index: Int) -> CGSize to specify the size for each image.
To response to some event on this control, you can either implement these optional delegate method:
@objcprotocolPhotoStackViewDelegate:NSObjectProtocol{optionalfunc stackView(stackView:PhotoStackView, didSelectPhotoAtIndex index:Int)optionalfunc stackView(stackView:PhotoStackView, willBeginDraggingPhotoAtIndex index:Int)optionalfunc stackView(stackView:PhotoStackView, didRevealPhotoAtIndex index:Int)optionalfunc stackView(stackView:PhotoStackView, willFlickAwayPhotoFromIndex from:Int, toIndex to:Int)}or use addTarget:action:forControlEvents: to add action listener. All control events it support are TouchDown, TouchCancel, TouchDragInside and TouchUpInside.
###Example
//declare some properties
varphotos=[UIImage(named:"github_1.jpeg"),UIImage(named:"github_2.jpeg"),UIImage(named:"github_3.jpeg")]letps=PhotoStackView()
//viewDidLoad()
ps.delegate =self
ps.dataSource =self
ps.frame =CGRect(x:120, y:50, width:80, height:80)
view.addSubview(ps)
ps.addTarget(self, action:Selector("touchDown"), forControlEvents:.TouchDown)
//touchDown action listener
func touchDown(){println("touchDown")}
//data source
func numberOfPhotosInStackView(stackView:PhotoStackView)->Int{return photos.count
}func stackView(stackView:PhotoStackView, imageAtIndex index:Int)->UIImage{returnphotos[index]!
}func stackView(stackView:PhotoStackView, sizeOfPhotoAtIndex index:Int)->CGSize{returnCGSizeMake(80,80)}
//delegate
func stackView(stackView:PhotoStackView, willFlickAwayPhotoFromIndex from:Int, toIndex to:Int){println("from \(from) to \(to)")}###Images