PreviewTransition 4.1.0

PreviewTransition 4.1.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2019年4月
SPM支持 SPM

Alex KalinkinIgor Kolpachkov 维护。



  • 作者:
  • Juri Vasylenko

PREVIEW TRANSITION

Preview Transition 是一个带有动画效果的简单预览画廊 UI 控制器


我们专注于为移动应用和网站设计和编写定制 UI。

关注最新更新

为您的项目获取免费Mockup →

Twitter Travis Carthage compatible CocoaPods CocoaPods codebeat badge Donate

关于

该项目由Ramotion公司维护。
我们专注于移动应用程序和网站的定制UI设计和编码。

正在寻找为您项目开发人员吗?
该项目由Ramotion公司维护。我们专注于移动应用程序和网站的定制UI设计和编码。


可在此处找到可用的iPhone Mockup

需求

  • iOS 9.0+
  • Xcode 9

许可协议

Preview-transition遵循MIT许可协议发布。详情见LICENSE

安装

只需将源文件夹添加到您的项目中,或者如这样使用CocoaPods

pod "PreviewTransition"

或者,对于Carthage用户,只需将其添加到他们的Cartfile

github "Ramotion/preview-transition"

用法

  1. 导入PreviewTransition

  2. 创建由PTTableViewController继承的UITableViewController子类

  3. 添加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)
}
  1. 添加一个ParallaxCell

故事板:创建一个单元格并从 ParallaxCell 继承;别忘了设置标识符 <CellIdentifier>

或者通过编程方式:在 viewDidLoad 中注册单元格 tableView.registerClass(ParallaxCell, forCellReuseIdentifier:]

  1. 设置单元格高度

  2. 创建图片名称(图片大小必须与屏幕大小相等或更大)

let images = [image_name, image_name, image_name, image_name, image_name] // image names
  1. 为 ParallaxCell 设置图片和文字
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: UITableView, didSelectRowAtIndexPath indexPath:) 我们将在后面添加。(步骤 10)

  1. 创建 UIViewController,继承自 PTDetailViewController

  2. 为 backButton 添加动作并调用 popViewController()

func backButtonHandler() {
    popViewController()
}
  1. 在 UITableViewController 中推入这个 UIViewController。添加方法
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)
  }
}
  1. 配置 UINavigationBar
// 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
      ]
}

📄许可证

Preview Transition 以下 MIT 许可证发布。有关详细信息,请参阅 LICENSE

此库是我们精选的最好 UI 开源项目之一。我们的最佳 UI 开源项目之一。

如果您在项目中使用开源库,请确保引用和反向链接到 www.ramotion.com

📱获取 iOS 的 Showroom App 进行尝试

在我们的 iOS 应用中尝试此 UI 组件和其他类似组件。如有兴趣,请联系我们。