본문 바로가기

#iOS

[iOS] Kingfisher 이미지 다운로드시, Authentication with NSURLCredential 이건 혹시, 테스트 서버에 접근 할 때, SSL 인증을 통과 시키고자 하시는 분들에게 도움을 드리고자 공유 합니다.iOS 출시를 위한 서버로 접근은 이 코드를 적용 시켜서는 안됩니다. 먼저 , .plist에 예외 처리 설정을 추가 합니다. NSAppTransportSecurityNSAllowsArbitraryLoads 우선, Kingfisher wiki에 SSL 인증과 관련 해서 아래와 같은 내용이 있다. Modify a request before sendinglet modifier = AnyModifier { request in var r = request r.setValue("", forHTTPHeaderField: "Access-Token") return r } imageView.kf.setImag.. 더보기
[iOS] 키보드 강제로 내리기 12345@IBAction func 특정이벤트 메소드(_ sender: AnyObject) { // sender가 UITextView 이거나 UITextField 일경우 // 그렇지 않을 경우 sender를 UITextView나 UITextField로 변경 해주세요. _ = sender.resignFirstResponder()}Colored by Color Scriptercs 위와 같이 UITextView 나 UITextField 에 resignFirstResponder 함수를 호출 하면 된다. 참고 : http://www.techotopia.com/index.php/Writing_iOS_7_Code_to_Hide_the_Keyboard 더보기
[iOS] Assets image stretching Android 에는 NinePatching이라는 좋은 기능이 있습니다.이미지를 원하는 형태로 stretching 해주지요. iOS는 어떻게 해야 할까요?? 위 화면 에서 우측 하단에 보시면 Slicing 이라는 부분이 있습니다.여기서 이미지를 어떻게 Stretch 할지 결정 할 수가 있어요. Nine Patch 처럼 자세하게는 안되지만 어느정도 조절은 가능해 보이네요. 이 속성은 이미지 파일을 하나 선택 해야 나오는 거구요.디폴트는 사용 안함 으로 되어 있다는 것을 참고 하세요. 더보기
[iOS] HTML 태그에 UIFont 적용 하기 UILabel 에 font를 적용 시키더라도 아래와 같이 HTML로 attributedText를 적용 하면 font가 변경 되어 버립니다. 1234567891011121314151617181920 fileprivate func getAttributedBodyText(_ html: String) -> NSMutableAttributedString { do { let str = try NSMutableAttributedString(data: html.data(using: .utf8, allowLossyConversion: true)! , options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentA.. 더보기
[iOS][Swift] Swift에서 DeviceToken 얻기 func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { var token: String = "" for i in 0.. 더보기
[iOS][Animation] 혹시 CAKeyframeAnimation이 동작하지 않을때 CAKeyframeAnimation을 사용하여 잘 동작을 하다가,백그라운드에서 포그라운드로 이동할 경우Animation이 멈춰버리는 현상이 발생 animation.isRemovedOnCompletion = false 위와 같이 Animation에 isRemovedOnCompletions에 false를 줘보세요~ DiscussionWhen true, the animation is removed from the target layer’s animations once its active duration has passed. Defaults to true.https://developer.apple.com/reference/quartzcore/caanimation/1412458-isremovedoncompleti.. 더보기
[iOS] 백그라운드, 포그라운드 확인 iOS는 전혀 App이 Background 인지 Foreground 인지 지원 알려주는 함수가 있다. AppDelegate.swift를 보시면 func applicationDidEnterBackground(_ application: UIApplication) {}func applicationWillEnterForeground(_ application: UIApplication) { } 위 두 함수를 통해서 파악을 할 수 있다! 하지만 이건 AppDelegate 인데, ViewController에서 어떻게 콜백을 받냐??구글링 해보면 여러가지가 있는데요. 그중에서 전 NotificationCenter를 이용하면 아주 쉽게 콜백을 받을 수 있습니다. 12345678910111213141516171819ove.. 더보기
[iOS][Swift] NavigationController 화면 전환 시 애니메이션 ## CATransition 이용 let transition = CATransition() transition.duration = 0.3 transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) transition.type = kCATransitionFade self.navigationController?.view.layer.add(transition, forKey: nil) self.navigationController?.pushViewController(targetViewController, animated: false) ## UIView Aniamtion 이용UIView.animate(wit.. 더보기