第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從UIBezierPath獲取點列表?

如何從UIBezierPath獲取點列表?

胡子哥哥 2019-11-18 10:18:22
我有一個UIBezierPath,我需要從中獲取要點列表。在Qt其中,有一個函數(shù)pointAtPercent可以滿足我的需求,但找不到等效的函數(shù)Objective-C。有誰知道如何做到這一點?
查看完整描述

3 回答

?
阿晨1998

TA貢獻2037條經(jīng)驗 獲得超6個贊

為了找到一個像雨燕解決方案,我在這整個的做法strumbled 后實施了CGPath擴展像這樣得到的路徑點:


extension CGPath {

    func points() -> [CGPoint]

    {

        var bezierPoints = [CGPoint]()

        self.forEach({ (element: CGPathElement) in

            let numberOfPoints: Int = {

                switch element.type {

                case .MoveToPoint, .AddLineToPoint: // contains 1 point

                    return 1

                case .AddQuadCurveToPoint: // contains 2 points

                    return 2

                case .AddCurveToPoint: // contains 3 points

                    return 3

                case .CloseSubpath:

                    return 0

                }

            }()

            for index in 0..<numberOfPoints {

                let point = element.points[index]

                bezierPoints.append(point)

            }

        })

        return bezierPoints

    }


    func forEach(@noescape body: @convention(block) (CGPathElement) -> Void) {

        typealias Body = @convention(block) (CGPathElement) -> Void

        func callback(info: UnsafeMutablePointer<Void>, element: UnsafePointer<CGPathElement>) {

            let body = unsafeBitCast(info, Body.self)

            body(element.memory)

        }

        let unsafeBody = unsafeBitCast(body, UnsafeMutablePointer<Void>.self)

        CGPathApply(self, unsafeBody, callback)

    }

}

查看完整回答
反對 回復(fù) 2019-11-18
  • 3 回答
  • 0 關(guān)注
  • 762 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號