40照片編輯App|文字/拍立得. 傳遞資料到下一頁 - Medium

文章推薦指數: 80 %
投票人數:10人

傳遞資料到下一頁. “#40照片編輯App |文字/拍立得” is published by Yang Y in 彼得潘的Swift iOS App 開發教室. 學生心得學習資源iOSApp課程#40照片編輯App|文字/拍立得傳遞資料到下一頁YangYFollowMay3·4minread前篇:#36照片編輯App—選照片nina39490.medium.com#36–2照片編輯App—旋轉/鏡射/裁切nina39490.medium.com#36–3照片編輯App—亮度/對比/飽和度/濾鏡/顏色nina39490.medium.compolaroidViewController(編輯拍立得頁面)📌畫面載入&按下相簿時,呼叫photoLibrary可以從相簿裡選照片overridefuncviewDidLoad(){super.viewDidLoad()openLibrary()}funcopenLibrary(){letcontroller=UIImagePickerController()controller.sourceType=.photoLibrarycontroller.delegate=selfpresent(controller,animated:true,completion:nil)}📌定義Function(將所選擇的照片顯示在ImageView)funcimagePickerController(_picker:UIImagePickerController,didFinishPickingMediaWithInfoinfo:[UIImagePickerController.InfoKey:Any]){letimage=info[.originalImage]as?UIImagepolaroidImg.image=imagedismiss(animated:true,completion:nil)}📌打完按下return收回鍵盤📌傳遞資料@IBSegueActionfuncresultPolaroid(_coder:NSCoder)->printViewController?{letpolaroid=polaroidImg.imageguardletphototext=phototext.textelse{returnnil}returnprintViewController(coder:coder,polaroid:polaroid!,phototext:phototext)}printViewController(印出照片)📌接收資料init?(coder:NSCoder,polaroid:UIImage,phototext:String){self.polaroid=polaroidself.phototext=phototextsuper.init(coder:coder)}requiredinit?(coder:NSCoder){fatalError(“init(coder:)hasnotbeenimplemented”)}📌存取照片@IBActionfuncsavePolaroid(_sender:UIButton){letrenderer=UIGraphicsImageRenderer(size:photoView.bounds.size)letimage=renderer.image(actions:{(context)inphotoView.drawHierarchy(in:photoView.bounds,afterScreenUpdates:true)})letactivityViewController=UIActivityViewController(activityItems:[image],applicationActivities:nil)present(activityViewController,animated:true,completion:nil)}GIF:GitHub:ninayang036/PhotoEditorContributetoninayang036/PhotoEditordevelopmentbycreatinganaccountonGitHub.github.com彼得潘的SwiftiOSApp開發教室學習SwiftiOSApp開發的學生作品集66Swift66 claps66彼得潘的SwiftiOSApp開發教室學習SwiftiOSApp開發的學生作品集WrittenbyYangYFollow彼得潘的SwiftiOSApp開發教室學習SwiftiOSApp開發的學生作品集



請為這篇文章評分?