此项目由Ramotion,Inc.维护。
我们专门从事移动应用和网站的定制UI设计和编码。
寻找您的项目的开发者吗?
您可在此找到iPhone mockup。
Preview-transition是基于MIT许可证发布的。
有关详情,请参阅LICENSE。
只需将源文件夹添加到您的项目中,或者像这样使用CocoaPods
pod "PreviewTransition", "~> 2.0.1" swift 3
pod "PreviewTransition", "~> 1.1.5" swift 2
或对Carthage用户,只需简单地将它添加到他们的Cartfile
github "Ramotion/preview-transition"
import PreviewTransition
创建继承自PTTableViewController
的UITableViewController子类
添加UITableViewDelegate方法
public override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return <RowsCount>
}
public override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
return tableView.dequeueReusableCellWithIdentifier(<CellIdentifier>, forIndexPath: indexPath)
}
storyboards
创建一个继承自ParallaxCell
的cell;不要忘记设置identifier <CellIdentifier>
或以编程方式
在viewDidLoad中注册cell tableView.registerClass(ParallaxCell, forCellReuseIdentifier:<CellIdentifier>)
设置cell高度
创建图像名称(图像尺寸必须等于屏幕尺寸或更大)
let images = [image_name, image_name, image_name, image_name, image_name] // image names
public override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
guard let cell = cell as? ParallaxCell else {
return
}
let imageName = images[indexPath.row]
if let image = UIImage(named: imageName) {
cell.setImage(image, title: <SetText>)
}
}
您的tableViewController应该看起来像DemoTableViewController
我们将稍后添加的方法 public override func tableView(tableView: didSelectRowAtIndexPath indexPath:)
。(第10步)
创建继承自PTDetailViewController
的UIViewController
为backButton添加动作并调用popViewController()
func backButtonHandler() {
popViewController()
}
public override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// create viewController
let <YourViewController> = storyboard?.instantiateViewControllerWithIdentifier(<identifier>)
if case let viewController as <YourViewController> = viewController {
pushViewController(viewController)
}
}
// transparent background
UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarMetrics: .Default)
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().translucent = true
UINavigationBar.appearance().tintColor = .whiteColor()
// set font
if let font = UIFont(name: <Font name> , size: 18) {
UINavigationBar.appearance().titleTextAttributes = [
NSForegroundColorAttributeName : UIColor.whiteColor(),
NSFontAttributeName : font
]
}