Tocropviewcontroller: ์Šค์œ„ํ”„ํŠธ 3 ์ง€์›

์— ๋งŒ๋“  2016๋…„ 10์›” 04์ผ  ยท  6์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: TimOliver/TOCropViewController

์ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ Swift 3์—์„œ ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

enhancement question

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

์ด ํ”„๋กœ์ ํŠธ๋Š” Objective-C๋กœ ์ž‘์„ฑ๋˜์—ˆ์œผ๋ฉฐ Swift 3 ๋˜๋Š” ๋‹ค๋ฅธ Swift ๋ฒ„์ „ ์ฝ”๋“œ์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ์ฝ”๋“œ๋ฅผ ๋ณ€๊ฒฝํ•  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ํ”„๋กœ์ ํŠธ. ๋”ฐ๋ผ์„œ CocoaPods๋ฅผ ํ†ตํ•ด ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ Swift์˜ Readme์—์„œ '๊ธฐ๋ณธ ๊ตฌํ˜„' ์˜ˆ์ œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

import TOCropViewController

func presentCropViewController() {
    let image: UIImage = ... // Load an image
    let cropViewController = TOCropViewController(image: image)
    cropViewController.delegate = self
    present(cropViewController, animated: true, completion: nil)
}

func cropViewController(_ cropViewController: TOCropViewController!, didCropTo image: UIImage!, with cropRect: CGRect, angle: Int) {
    // 'image' is the newly cropped version of the original image
}

์†Œ์Šค๋ฅผ Swift ํ”„๋กœ์ ํŠธ์— ๋ณต์‚ฌํ•˜๋Š” ๊ฒฝ์šฐ https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html์—์„œ 'Objective-C๋ฅผ Swift๋กœ ๊ฐ€์ ธ์˜ค๊ธฐ' ์„น์…˜์„

๋ชจ๋“  6 ๋Œ“๊ธ€

Objective-C ๋ธŒ๋ฆฌ์ง• ํ—ค๋”๋ฅผ ์ถ”๊ฐ€ํ•  ๋•Œ ๋“œ๋กญํ•˜๋ฉด ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค! :)

์–ด๋Š ์‹œ์ ์—์„œ API ๋””์ž์ธ์„ ๊ฐœ์„ ํ•˜์—ฌ ๋” 'Swifty'ํ•˜๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

cocoapods๋ฅผ ํ†ตํ•ด Swift 3 ํ”„๋กœ์ ํŠธ์—์„œ TOCropViewController๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š”๋ฐ ์˜ค๋ฅ˜ ์—†์ด ์ž˜ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

์šฐ๋ฆฌ๋Š” ๋น ๋ฅธ ๋ฒ„์ „์„ ๊ธฐ๋Œ€ํ•ฉ๋‹ˆ๋‹ค # @akovalov :) :) :)

@osmanyildirim ๋ฌด๋ฃŒ ์˜คํ”ˆ ์†Œ์Šค ํ”„๋กœ์ ํŠธ์— ๋Œ€ํ•ด '๊ธฐ๋Œ€'ํ•˜๋Š” ๊ฒƒ์€ ์‹ค์ œ๋กœ ๋ถˆ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ;)

๊ธฐ๋ณธ Swift 3 ์ง€์›์ด ์ ˆ์‹คํžˆ ํ•„์š”ํ•œ ๊ฒฝ์šฐ ์ง์ ‘ ๊ตฌํ˜„ํ•˜์‹ญ์‹œ์˜ค. :NS

์ด ํ”„๋กœ์ ํŠธ๋Š” Objective-C๋กœ ์ž‘์„ฑ๋˜์—ˆ์œผ๋ฉฐ Swift 3 ๋˜๋Š” ๋‹ค๋ฅธ Swift ๋ฒ„์ „ ์ฝ”๋“œ์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ์ฝ”๋“œ๋ฅผ ๋ณ€๊ฒฝํ•  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ํ”„๋กœ์ ํŠธ. ๋”ฐ๋ผ์„œ CocoaPods๋ฅผ ํ†ตํ•ด ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ Swift์˜ Readme์—์„œ '๊ธฐ๋ณธ ๊ตฌํ˜„' ์˜ˆ์ œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

import TOCropViewController

func presentCropViewController() {
    let image: UIImage = ... // Load an image
    let cropViewController = TOCropViewController(image: image)
    cropViewController.delegate = self
    present(cropViewController, animated: true, completion: nil)
}

func cropViewController(_ cropViewController: TOCropViewController!, didCropTo image: UIImage!, with cropRect: CGRect, angle: Int) {
    // 'image' is the newly cropped version of the original image
}

์†Œ์Šค๋ฅผ Swift ํ”„๋กœ์ ํŠธ์— ๋ณต์‚ฌํ•˜๋Š” ๊ฒฝ์šฐ https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html์—์„œ 'Objective-C๋ฅผ Swift๋กœ ๊ฐ€์ ธ์˜ค๊ธฐ' ์„น์…˜์„

๋‚˜๋Š” ์ด ํ”„๋กœ์ ํŠธ์— ๋” ๋‚˜์€ Swift ์ƒํ˜ธ ์šด์šฉ์„ฑ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐ ์•ฝ๊ฐ„์˜ ๋…ธ๋ ฅ์„ ๊ธฐ์šธ์˜€์Šต๋‹ˆ๋‹ค. NS_SWIFT_NAME ์‚ฌ์šฉํ•˜์—ฌ ๋ฉ”์„œ๋“œ ์ด๋ฆ„์„ ์™„์ „ํžˆ ๋ฆฌํŒฉํ† ๋งํ•˜๋Š” ๊ฒƒ ์™ธ์—๋Š” ์šฐ๋ฆฌ๊ฐ€ ํ•  ์ˆ˜ ์žˆ๋Š” ๋งŒํผ๋งŒ ํ•˜๋ฉด ๋œ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

Swift interop์„ ๊ฐœ์„ ํ•˜๋Š” ๋ฐ ํ•„์š”ํ•œ ๋‹ค๋ฅธ ์‚ฌํ•ญ์ด ์ƒ๊ฐ๋‚˜์‹œ๋ฉด PR์„ ์ œ์ถœํ•˜์„ธ์š”. :)

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰