• Swift开发之3DTouch实用演练 2015年,苹果发布了iOS9以及iphone6s/iphone6s Plus,其中最具有创新的就是新的触控方式3D Touch,相对于多点触摸在平面二维空间的操作,3D Touch技术增加了对力度和手指面积的感知,...

    Swift开发之3DTouch实用演练

    2015年,苹果发布了iOS9以及iphone6s/iphone6s Plus,其中最具有创新的就是新的触控方式3D Touch,相对于多点触摸在平面二维空间的操作,3D Touch技术增加了对力度和手指面积的感知,可以通过长按快速预览、查看你想要的短信、图片或者超链接等内容,Peek和Pop手势的响应时间可迅捷到 10ms和15ms等。

    • 用户现在可以按主屏幕图标立即访问应用程序提供的功能。
    • 在您的应用程序中,用户现在可以按视图来查看其他内容的预览,并获得对功能的加速访问
    • 在日常开发中,我们经常需要使用3D Touch中的两个功能
      • 在主屏幕上对应用图标使用3DTouch操作
      • 在应用程序内对某一控件使用3DTouch操作
    • 功能需要iOS9以上系统和iphone6s/iphone6s Plus及以上机型(模拟机现在也是可以的)
    • demo地址

    一. 效果演练

    1. 主屏幕快速操作

    • 通过按下iPhone 6s或iPhone 6s Plus上的应用程序图标,用户可以获得一组快速操作。
    • 当用户选择快速操作时,您的应用程序激活或启动,并跳转到相应界面
      主屏幕快速操作

    2. Peek and Pop

    • 对界面内某一控件的3DTouch操作
    • Peek和Pop是应用内的一种全新交互模式,当用户不断增加力量在控件上按压,会依次进入四个阶段
    • 轻按控件,除触发Peek的控件外,其他区域全部虚化
    • 继续用力Peek被触发,展示Pop界面快照
    • 向上滑动展示快捷选项
    • 继续用力跳转进入Pop界面

    轻按控件,除触发Peek的控件外,其他区域全部虚化

    继续用力Peek被触发,展示Pop界面快照

    向上滑动展示快捷选项

    3. 注意

    • 3D Touch仅在3D Touch设备上可用,如果启用。在iOS 9以上,默认情况下启用3D Touch。
    • 用户可以在设置>常规>辅助功能> 3D触摸中关闭3D触摸。
    • 当3D Touch可用时,利用其功能。当它不可用时,提供替代方法,例如通过使用触摸和保持。
    • 3D Touch功能支持VoiceOver。

    二. 主屏幕操作

    • ShortcutItem功能允许用户在主屏幕上对应用图标使用3DTouch操作,如果本次操作有效,则会给出几个快捷可选项允许用户进行操作
    • 主屏幕icon上的快捷标签的实现方式有两种,一种是在工程文件info.plist里静态设置,另一种是代码的动态实现
    • 优先显示静态添加,总数达到4个不再显示

    1. 静态设置

    • 在info.plist中添加UIApplicationShortcutItems关键字,以如下方式配置即可

    UIApplicationShortcutItems配置

    其中各个关键字释义如下:
    - UIApplicationShortcutItemType: 快捷可选项的特定字符串(必填)
    - UIApplicationShortcutItemTitle: 快捷可选项的标题(必填)
    - UIApplicationShortcutItemSubtitle: 快捷可选项的子标题(可选)
    - UIApplicationShortcutItemIconType: 快捷可选项的图标(可选)
    - UIApplicationShortcutItemIconFile: 快捷可选项的自定义图标(可选)
    - UIApplicationShortcutItemUserInfo: 快捷可选项的附加信息(可选)

    2. 动态添加UIApplicationShortcutItem

    2-1. UIApplicationShortcutItem初始化方法

    UIApplicationShortcutItem(type: String, localizedTitle: String, localizedSubtitle: String?, icon: UIApplicationShortcutIcon?, userInfo: [AnyHashable : Any]?)
    • 参数介绍
      • type: 快捷可选项的特定字符串(必填)
      • localizedTitle: 快捷可选项的标题(必填)
      • localizedSubtitle: 快捷可选项的子标题(可选)
      • icon: 快捷可选项的图标(可选)
      • userInfo: 快捷可选项的附加信息(可选)

    2-1. 图标

    2-1-1. 初始化方式
    //方式一: 自定义图标
    //注: 自定义图标需要使用镂空图标,同时建议1倍图标大小为35*35
    UIApplicationShortcutIcon(templateImageName: String)
    
    //方式二: 使用系统图标
    UIApplicationShortcutIcon(type: UIApplicationShortcutIconType)
    2-1-2. 系统图标样式如下

    系统图片一览表

    2-3. 具体实现代码如下

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    
        //3D Touch
        let homeIcon = UIApplicationShortcutIcon(type: .compose)
        let homeItem = UIApplicationShortcutItem(type: "homeAnchor", localizedTitle: "首页", localizedSubtitle: "点击进入首页", icon: homeIcon, userInfo: nil)
        let playIcon = UIApplicationShortcutIcon(type: .play)
        let playItem = UIApplicationShortcutItem(type: "play", localizedTitle: "播放", localizedSubtitle: "", icon: playIcon, userInfo: nil)
        let userIcon = UIApplicationShortcutIcon(type: .search)
        let userItem = UIApplicationShortcutItem(type: "username", localizedTitle: "用户名", localizedSubtitle: "", icon: userIcon, userInfo: nil)
    
        UIApplication.shared.shortcutItems = [homeItem, playItem, userItem]
    
        return true
    }
    

    2-4. item点击跳转

    • 可根据type标识判断
    • 可根据localizedTitle标识判断
    //菜单跳转
    func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
        guard let tabBarVC = window?.rootViewController as? MainViewController else { return }
    
        //根据type唯一标识进行判断跳转, 或者根据localizedTitle判断
        switch shortcutItem.type {
        case "homeAnchor":
            tabBarVC.selectedIndex = 1
        case "play":
            let username = ShowRoomViewController()
            username.hidesBottomBarWhenPushed = true
            tabBarVC.selectedViewController?.childViewControllers.first?.present(username, animated: true, completion: nil)
        case "username":
            let username = NameViewController()
            username.hidesBottomBarWhenPushed = true
            tabBarVC.selectedViewController?.childViewControllers.last?.navigationController?.pushViewController(username, animated: true)
        default:
            tabBarVC.selectedIndex = 0
        }
    }
    

    三. Peek and Pop

    • Peek和Pop是应用内的一种全新交互模式,当用户不断增加力量在控件上按压,会依次进入四个阶段
    • 这里小编将通过ViewController里面的UITableViewCell进行延时功能

    注意: 在动态添加快捷可选项前,需要用判断是否支持3D Touch功能,以免在不支持的设备上运行程序导致闪退

    1. 判断是否支持3D Touch功能

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCell(withIdentifier: "cell")
        let model = happyVM.anchorGroups[indexPath.section].anchors[indexPath.row]
        if cell == nil {
            cell = UITableViewCell(style: .default, reuseIdentifier: "cell")
            cell?.textLabel?.text = model.room_name
            cell?.accessoryType = .disclosureIndicator
        }
    
    ---
        //这里是添加判断是否支持3D Touch的代码
        if #available(iOS 9.0, *) {
            if traitCollection.forceTouchCapability == .available {
                //支持3D Touch
                //注册Peek & Pop功能
                registerForPreviewing(with: self, sourceView: cell!)
            }
        }
    ---
    
        return cell!
    }
    

    检测是否支持3D Touch:UIForceTouchCapability是一个枚举值,取值如下:

    case unknown      //3D Touch检测失败
    case unavailable //3D Touch不可用
    case available  //3D Touch可用

    2. 给对应view注册3Dtouch事件

    • 在判断支持3Dtouch里面注册
    //注册Peek & Pop功能
    self.registerForPreviewing(with: self, sourceView: cell!)

    3. 遵守UIViewControllerPreviewingDelegate协议

    • 需要实现Peek & Pop交互的控件所在的控制器遵循协议并实现两个代理方法

    3-1. 当进入Peek状态时,系统会回调如下方法

    func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
        //1. 获取按压的cell所在的行
        guard let cell = previewingContext.sourceView as? UITableViewCell else { return UIViewController() }
        let indexPath = tableVIew.indexPath(for: cell) ?? IndexPath(row: 0, section: 0)
    
        //2. 设定预览界面
        let vc = ShowRoomViewController()
        // 预览区域大小(可不设置), 0为默认尺寸
        vc.preferredContentSize = CGSize(width: 0, height: 0)
        vc.showStr =  "我是第\(indexPath.row)行用力按压进来的"
    
        //调整不被虚化的范围,按压的那个cell不被虚化(轻轻按压时周边会被虚化,再少用力展示预览,再加力跳页至设定界面)
        let rect = CGRect(x: 0, y: 0, width: kScreenWidth, height: 44)
        //设置触发操作的视图的不被虚化的区域
        previewingContext.sourceRect = rect
    
        //返回预览界面
        return vc
    }
    

    3-2. 当进入Pop状态时,系统会回调如下方法

    • 用力按压进入viewControllerToCommit
    func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
        viewControllerToCommit.hidesBottomBarWhenPushed = true
        show(viewControllerToCommit, sender: self)
    }
    

    来看看效果

    3D Touch1演示.gif

    3-4. 当弹出预览时,上滑预览视图,出现预览视图中快捷选项

    var previewActionItems: [UIPreviewActionItem] { get }
    • previewActionItems用户在3D Touch预览上向上滑动时显示的快速操作
    • 在将要弹出的页面内重写previewActionItems的get属性
    extension ShowRoomViewController {
        //重写previewActionItems的get方法
        override var previewActionItems: [UIPreviewActionItem] {
            let action1 = UIPreviewAction(title: "跳转", style: .default) { (action, previewViewController) in
                let showVC = ShowRoomViewController()
                showVC.hidesBottomBarWhenPushed = true
                previewViewController.navigationController?.pushViewController(showVC, animated: true)
            }
    
            let action3 = UIPreviewAction(title: "取消", style: .destructive) { (action, previewViewController) in
                print("我是取消按钮")
            }
    
            ////该按钮可以是一个组,点击该组时,跳到组里面的按钮。
            let subAction1 = UIPreviewAction(title: "测试1", style: .selected) { (action, previewViewController) in
                print("我是测试按钮1")
            }
            let subAction2 = UIPreviewAction(title: "测试2", style: .selected) { (action, previewViewController) in
                print("我是测试按钮2")
            }
            let subAction3 = UIPreviewAction(title: "测试3", style: .selected) { (action, previewViewController) in
                print("我是测试按钮3")
            }
            let groupAction = UIPreviewActionGroup(title: "更多", style: .default, actions: [subAction1, subAction2, subAction3])
    
            return [action1, action3, groupAction]
        }
    }
    

    action的各种样式

    public enum UIPreviewActionStyle : Int {
    
        //默认样式
        case `default`
        //右侧有对勾的样式
        case selected
        //红色字体的样式
        case destructive
    }

    3-5. forcemaximumPossibleForce

    到此,3DTouch在APP中的集成就先介绍这些,3DTouch中还有个重要的属性–压力属性(force 和 maximumPossibleForce)这里简单介绍下

    • 手指在屏幕上慢慢增加力度在减少力度,可以看到view背景色的变化
    • 程序运行后找到我的 -> 头像(用户名)查看效果
    • 代码找到NameViewController.swift查看
    
    override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
        let touch = touches.first ?? UITouch()
        //获取重按力度
        print("平均触摸的力--\(touch.force)")
        print("触摸的最大可能力--\(touch.maximumPossibleForce)")
    
        let change = touch.force / touch.maximumPossibleForce
            view.backgroundColor = UIColor(red: 0.5, green: 0.5, blue: change, alpha: 1)
    }
    

    此外还有以下属性, 详细可参考3D Touch官方文档

    var tapCount: Int
    //手指触摸此次触摸的次数。
    
    var timestamp: TimeInterval
    //触摸发生的时间或最后一次突变的时间。
    
    var type: UITouchType
    //触摸的类型。
    
    enum UITouchType
    //接收的触摸类型。
    
    var phase: UITouchPhase
    //触摸的阶段。
    
    enum UITouchPhase
    //手指触摸的阶段。
    
    var maximumPossibleForce: CGFloat
    //触摸的最大可能力。
    
    var force: CGFloat
    //触摸力,其中值表示平均触摸的力(由系统预定,不是用户特定的)。1.0
    
    var altitudeAngle: CGFloat
    //手写笔的高度(弧度)。
    
    func azimuthAngle(in: UIView?)
    //返回触控笔的方位角(弧度)。
    
    func azimuthUnitVector(in: UIView?)
    //返回指向触控笔方位角方向的单位向量。

    最后附上Demo地址


    参考资料

    iOS 3D touch开发

    3D Touch官方文档

    展开全文
  • swift 3d 入门教程

    2020-06-05 23:30:59
    为了让大家快速了解SWIFT 3D的一些概念,我们先做一个简单的文字转到效果,我将一步步教你怎么做,请跟着做...............
  • 转载自己的简书 最新iOS 整合Unity(xCode9.1 Swift4.0 Unity5.4)http://www.jianshu.com/p/966aab820516


    转载自己的简书

    最新iOS 整合Unity(xCode9.1 Swift4.0 Unity5.4)http://www.jianshu.com/p/966aab820516

    展开全文
  • 著名移动开发教学网站RayWenderlich 出品的付费电子书。基于Swift 4版本的3D 游戏开发教程
  • 整天逛淘宝,偶尔有一天看到其中的展示页有个看起来很炫的效果,闲来无事就试着写一个出来,先来看效果:简单记一下思路,这里我选择使用UICollectionView控件,先根据其复用和滚动的特性做出无限轮播的效果,关键...

    整天逛淘宝,偶尔有一天看到其中的展示页有个看起来很炫的效果,闲来无事就试着写一个出来,先来看效果:

    简单记一下思路,这里我选择使用UICollectionView控件,先根据其复用和滚动的特性做出无限轮播的效果,关键代码:

    //数据源数组
        let totalCount = 100
        var models: [String] = [String]() {
            didSet {
                //判断元素个数
                if models.count < 2 {
                    collectionView.isScrollEnabled = false
                }
                //网上的找来的一个办法添加100组数据源对应的索引数组indexArr
                for _ in 0..<totalCount {
                    for j in 0..<models.count {
                        indexArr.append(j)
                    }
                }
                //开始就滚动到第50组数据源
                collectionView.scrollToItem(at: IndexPath(item: totalCount/2 * models.count, section: 0), at: .centeredHorizontally, animated: false)
            }
        }

    滚动停止时走的方法里做处理:

    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
            //找到滚动停止的点对应的collectionView的indexPath
            let point =  self.convert(collectionView.center, to: collectionView)
            let index = collectionView.indexPathForItem(at: point)
            let indexpath = (index?.row ?? 0) % models.count
            
            collectionView.scrollToItem(at: IndexPath(item: totalCount/2 * models.count + indexpath, section: 0), at: .centeredHorizontally, animated: false)
        }
    以上是滚动的处理,接下来就是item的渐变效果处理,看到这种情况就想到要写一个UICollectionViewFlowLayout
    类供collectionView使用,UICollectionViewFlowLayout是管理item怎么展示用的,首先重写展示视图内的layoutAttributes方法,在此方法中找到attribute对应的item及其属性,和collectionView的偏移量和中心点,进行一系列的计算:

    override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
            
            //集合视图的宽高(这里默认宽高相等)
            let itemHeight = self.collectionView?.frame.height ?? 0
            //可是视图内的attributes数组
            let array = super.layoutAttributesForElements(in: rect)
            //item透明度开始变化时的item的中心点x
            let centerX = self.collectionView!.contentOffset.x + itemHeight/2
            print(self.collectionView?.contentOffset.x ?? 0)
            
            for attributes in array! {
                //开始变化时的item的中心点x 与 实际中心点相比较
                let value = attributes.center.x - centerX
                let delta = abs(value)
                //设置缩放比例,此处4*itemHeight可根据缩放效果进行修改
                let scale = 1 - delta/(4*itemHeight)
        
                //设置缩放比例
                attributes.transform = CGAffineTransform.init(scaleX: scale, y: scale)
                //层次关系,设置此属性使item依次上下排列
                attributes.zIndex = Int(1 - abs(delta))
                
                //value<=0表示向左移动,最前面的item停止一段距离
                if value <= 0{
                    //实际中心点与开始变化时的item的中心点小于等于设定的边界值
                    if delta >= 0 && delta <= itemHeight
                    {
                        //item的中心点固定不变
                        attributes.center.x = centerX
                        //根据推进值,改变item的透明度,此处的delta>10是想让item有一个达到目标区域时有一个停顿效果而不是直接进入改变透明度的阶段
                        attributes.alpha = (delta > 10) ? (1 - delta/(itemHeight/4)) : 1
                        //设置缩放比例,停顿阶段不进行缩放
                        attributes.transform = CGAffineTransform.init(scaleX: 1, y: 1)
                    } else {
                        //移动大于边界值,就是从停顿阶段到透明度改变,此处是下一个item上来,当前item透明度变为0
                        attributes.alpha = 0
                    }
                }
            }
            return array
        }

    解决最后一个小问题,拖动iitem开始滚动,滚动结束时让它自动滚动到网格区域,而不是停在当前或许不适当的地方,重写UICollectionViewFlowLayout另一个方法:

    override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint {
            
            let targetRect = CGRect(x: proposedContentOffset.x, y: 0.0, width: self.collectionView!.bounds.size.width, height: self.collectionView!.bounds.size.height)
            
            //目标区域中包含的cell
            let attrArray = super.layoutAttributesForElements(in: targetRect) as! [UICollectionViewLayoutAttributes]
            //collectionView落在屏幕重点的x坐标
            let horizontalCenterX = proposedContentOffset.x + (self.collectionView?.frame.height ?? 0)/2
            var offsetAdjustment = CGFloat(MAXFLOAT)
            for layoutAttributes in attrArray {
                
                let itemHorizontalCenterX = layoutAttributes.center.x
                //找出离中心店最近的
                if (abs(itemHorizontalCenterX-horizontalCenterX) < abs(offsetAdjustment)) {
                    offsetAdjustment = itemHorizontalCenterX - horizontalCenterX
                }
            }
            
            //返回collectionView最终停留的位置
            return CGPoint(x: proposedContentOffset.x + offsetAdjustment, y: proposedContentOffset.y)
            
        }
    //当collectionView的显示范围发生改变的时候,是否重新布局
        override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
            return true
        }

    最后一个方法不写看不到渐变的效果。

    源码地址:点击打开链接

    展开全文
  • 3D Touch swift 版本

    2015-12-01 15:24:58
    OSX 10.10.5 (14F27) XCODE Version 7.1.1 (7B1005) ...swift -version --->Apple Swift version 2.1 (swiftlang-700.1.101.6 clang-700.1.76) AppDelegate.swift: // // AppDelegate.swift // 3DTouchDemo /

    OSX 10.10.5 (14F27)

    XCODE Version 7.1.1 (7B1005)

    swift -version --->Apple Swift version 2.1 (swiftlang-700.1.101.6 clang-700.1.76)

    AppDelegate.swift:

    //
    //  AppDelegate.swift
    //  3DTouchDemo
    //
    //  Created by Johnson on 15/11/13.
    //  Copyright © 2015年 Johnson. All rights reserved.
    //
    
    import UIKit
    
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    
        var window: UIWindow?
    
    
        func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
            
            //给App图标添加3D Touch菜单  重按
            //拍照
            
            //菜单图标
            let cameraIcon = UIApplicationShortcutIcon(type: .Add)
            
            let cameraItem = UIMutableApplicationShortcutItem(type: "camera", localizedTitle: "拍照")
            
            cameraItem.icon = cameraIcon
            
            //给App图标添加3D Touch菜单
            //拍照
            let photoLibraryIcon = UIApplicationShortcutIcon(type: .Search)
    
            let photoLibrayItem =  UIMutableApplicationShortcutItem(type: "photos", localizedTitle: "相册")
            photoLibrayItem.icon = photoLibraryIcon
            
            
            application.shortcutItems = [cameraItem,photoLibrayItem]
            
            return true
        }
        
        
        func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {
            if shortcutItem.type == "camera"
            {
                let picker = UIImagePickerController()
                picker.allowsEditing = true
                picker.sourceType = UIImagePickerControllerSourceType.Camera
                
                //进入照相界面
                self.window?.rootViewController?.presentViewController(picker, animated: true, completion: nil)
                
            }
            else if shortcutItem.type == "photos"
            {
                let libraryPicker = UIImagePickerController()
                libraryPicker.allowsEditing = true
                libraryPicker.sourceType = UIImagePickerControllerSourceType.Camera
                
                //进入图片库
                self.window?.rootViewController?.presentViewController(libraryPicker, animated: true, completion: nil)
            }
        }
    
        func applicationWillResignActive(application: UIApplication) {
            // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
            // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
        }
    
        func applicationDidEnterBackground(application: UIApplication) {
            // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
            // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
        }
    
        func applicationWillEnterForeground(application: UIApplication) {
            // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
        }
    
        func applicationDidBecomeActive(application: UIApplication) {
            // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
        }
    
        func applicationWillTerminate(application: UIApplication) {
            // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
        }
    
    
    }
    
    

    在两个application级别的监听器函数中完成:1.对图标菜单的设置   2.当点击图标后的事件分配和处理


    另附上一个长按图片分享的效果:

    //
    //  ViewController.swift
    //  3DTouchDemo
    //
    //  Created by Johnson on 15/11/13.
    //  Copyright © 2015年 Johnson. All rights reserved.
    //
    
    import UIKit
    
    class ThreeDTouchViewController : UIViewController,UIViewControllerPreviewingDelegate {
    
        override func viewDidLoad() {
            super.viewDidLoad()
            
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    
         func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController?
        {
            //ASPreviewViewController
            return  nil
        }
        
         func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController)
        {
            
        }
        
        //预览时,添加底部菜单
        override func previewActionItems() -> [UIPreviewActionItem] {
            
            let shareItem = UIPreviewAction(title: "分享", style: UIPreviewActionStyle.Default) { (<#UIPreviewAction#>, <#UIViewController#>) -> Void in
                print("点击了分享")
            }
            
            let savingItem = UIPreviewAction(title: "收藏", style: UIPreviewActionStyle.Default) { (<#UIPreviewAction#>, <#UIViewController#>) -> Void in
                print("点击了收藏")
            }
            return [shareItem,savingItem]
        }
        
    }
    
    







    展开全文
  • Swift 写一个3D轮播图,支持循环滚动和点击
  • swift3d 4.5进步了

    2009-05-31 17:53:00
    swift3d 4.5进步了学了3d以后我所考虑的一点就是如何让flash和3d更紧密的结合,要考虑的首要问题就是文件的体积,网络的加载速度,再漂亮的flash动画等个10分钟,人也烦了,所以,这个基于此,有两个方法一就是用3d...

    swift3d 4.5进步了

    学 了3d以后我所考虑的一点就是如何让flash和3d更紧密的结合,要考虑的首要问题就是文件的体积,网络的加载速度,再漂亮的flash动画等个10分 钟,人也烦了,所以,这个基于此,有两个方法一就是用3dmax这个老家伙,还是公认的强大的软件,但是他导出的动画是avi,体积很大放在flash里 很不适合,所以需要把avi转换成swf,这就需要一个中间的转换软件flix。ildform公司出品的Flix是目前唯一一个能够把视频转换为SWF 媒体格式(flash动画)的软件。使用它,你就可以把AVI等格式的视频文件转换成较小的SWF文件,实现网上的流式播放!也许有些人说这样太麻烦了, 那么我给大家推荐swift3d4.5,他可以直接设置一下就轻松得倒入flash。Electric Rain的Swift3D是一个基于矢量的3D创作工具,设计师们能够迅速地从字体、基本3D元素和已有SWF格式3D模型创建3D图像。Swift 3D v4.5是Swift 3D v4的视频和矢量渲染升级。它是我们新近引入Swift 3D 的,可以导出FLV、AVI和Quicktime视频格式,提供新的矢量渲染选项。它是动画设计者们的最好的三维工具。

    Swift 3D v4.5新功能:


    FLV Video Export (Flash Video)
    FLV格式视频输出
    Export your Swift 3D animations to the Flash Video .FLV format for direct playback through the Macromedia Flash Player.



    Quicktime and AVI Video Export
    Quicktime 和 AVI格式视频输出
    Swift 3D now exports to AVI and Quicktime video formats, making it an essential tool for ALL of your motion design projects. Utilize your 3D videos as-is, or integrate them into your video projects and apply effects using popular video editing programs, such as Adobe After Effects. From simple 3D video titling to advanced 3D video animations, Swift 3D Version 4.5 broadens your design possibilities at an affordable price.



    Render Vector Style Animations to Video
    渲染矢量格式动画到视频
    Swift 3D is the industry-leader when it comes to 3D vector graphic rendering. Version 4.5 even allows you to export your vector-style animations to FLV, AVI, or Quicktime video formats!





    Pen Style Outlines
    笔绘轮廓
    Introducing customizable pen styles that apply variable pen-width strokes to your 3D objects, giving them true cartoon styling. Choose your pen shape, angle and aspect and let our RAViX 4 vector rendering engine output an optimized cartoon animation or vector image that will remind you of your Saturday morning cartoon favorites.




    Render Speeds up to 50 Times Faster!
    渲染速度比过去快50倍!
    Swift 3D v4.5 now utilize our latest RAViX 4 technology with vastly improved render times. These speed increases are particularly noticeable in low-polygon models and simple animations that use basic fill styles, where our benchmark testing showed increases of more than 50 times faster than what was possible using Version 4. Note: Speed increases vary substantially when rendering high-polygon models or when using complex render options.



    Shadow Density and Color Controls
    阴影密度和颜色控制
    The answer to one of our most requested user features! Easily control vector shadow density using a built in slider in the main render dialog. You can even choose the color of your rendered shadows to help produce the look you are after.



    Save and Load User-Defined Render Styles
    存取用户自定义渲染格式
    This convenient, time-saving feature allows users to save and load user-defined render styles directly from the render options dialog. When you have defined the style you’re after, simply choose the Save Settings option and name your render profile to be saved. The next time you want to use the same style, simply load the file and you’re ready to render within seconds. No more messing around with trying to duplicate previous styles!



    Enhancements to Vector Transparency Rendering
    改进的矢量透明渲染
    Transparent objects are now rendered with outlines and a new feature, Hidden Transparent Edges, allows you to render edges that would normally be obscured by the object. These edges are outlined in a softer manner than the edges exposed to the camera, giving your vector renderings a more realistic and finished look.




    Level 3 Support for EPS files
    EPS文件三级支持
    For designers that use Swift 3D v4.5 to output vector files for use in Adobe Illustrator, Macromedia Freehand, or other 2D vector drawing programs, Swift 3D now exports vector gradient shading styles (Area Shading and Mesh Shading) and shadows to the EPS file format for import into supporting programs.


    Outlines at Intersections
    交汇处的轮廓线
    When an outline style is chosen and this option is selected in the main render dialog, an outline will appear along the point where two objects intersect. Turn it off and Swift 3D renders an outline only around the silhouette of the intersecting objects.




    Two Pass Curve Fitting
    双重曲线拟合设置
    With this option selected, our RAViX vector renderer will take a second pass through the edges within your rendering and attempt to fit together groups of edges with a curve. While this option increases render time, it can help produce better results and smaller files



    展开全文
  • swift 显示3D地图

    2017-05-08 21:32:02
    在ios中设置3D地图需要添加一个“摄影机” ,“摄影机”是摄影机类 MKMapCamera 为了支持3D地图 MKMapView中添加了camera属性 , 该属性是MKMapCamera类型 “摄像机”有如下5个重要属性 centerCoordinate。...
  • 今天在网到有人实现了一个旋转菜单,我用CAKeyFrameAnimation(position)和CABasicAnimation(transform.scale...实现代码:都在一个swift即可。 1.先自定义一个UIButton类,添加两个属性 import UIKit class CustomBu
  • ARKit和SceneKit实现3D模型交互 这篇文章讲的是如何把AR模型添加到增强现实中,以及添加一些和用户的点击交互。 ARKit&SceneKit iOS 11引入了ARKit,这是一个新框架,可以让你在iPhone和iPad上轻松体验增强现实...
  • 3DSnakeAR 基于ARKit用Swift编写的著名贪吃蛇游戏
  • 今天来了解下CATransform3D的一些基本的知识。CATransform3D是一个用于处理3D形变的类,其可以改变控件的平移、缩放、旋转、斜交等,其坐标系统采用的是三维坐标系,即向右为x轴正方向,向下为y轴正方向,垂直屏幕向外为z...
  • 本文讲的是用 Swift 枚举完美实现 3D touch 快捷操作, 完美实现 3D Touch 我不确定是否一开始 Swift 的创造者们能够估计到他们创造的这一门极其优美的语言,将带给开发者们如此激昂的热情。 我只想说,Swift 社区...
  • Euclid 一个用于创建和操作3D几何体的Swift
  • Swift 2.3 IOS 8.0 XCode 8.0 添加入口标签在这里只说下静态的好了,暂时还用不到动态的,e.g.<key>UIApplicationShortcutItems <key>UIApplicationShortcutItemType <string>ReceiveMoney</s
  • swift3d界面介绍

    2020-04-24 23:33:44
    Swift3D Flash3D的好帮手,界面干净清爽,简单明了,教程讲解细致入微,令你一看就会。
  • Electric Rain ZAM 3DElectric Rain ZAM 3D是一个功能齐全的3D建模软件,可轻松创建,定制和动画基于Windows Vista 应用的3D界面要素。 一旦创建三维场景,Electric Rain ZAM 3D自动生成XAML(扩展应用程序标记语言...
  • 分享一个自己做的3d立方体(在瑞士航空见到过类似的这种首页),还可以添加以下要素变得更加完善: 1)旋转过程中每个面的透明度可以更改 2)手势滑动结束可以添加惯性转动动画  效果如图: 直接上代码...
  • Swift 3D 5.0 版本实现了与 Microsoft Silverlight 的集成,可以直接导出成Microsoft Silverlight 和 Windows Presentation Foundation(WPF) 3D 场景。 详细信息参见 ...
1 2 3 4 5 ... 20
收藏数 5,307
精华内容 2,122