반응형

iOS 197

[iOS, Swift] UITextField 특정 글자 제한하기

iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다. func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { let allowedCharacters = CharacterSet(charactersIn: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuxyz").inverted let components = string.components(separatedBy: allowedCharacters) let filtered = components.join..

iOS/코드조각 2022.08.21

[iOS, Swift] UIAlertController 텍스트 입력창 추가하기

iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다. let alert = UIAlertController(title: "Simple", message: "Simple Message with TextField", preferredStyle: .alert) let defaultAction = UIAlertAction(title: "OK", style: .default) { (action) in } alert.addAction(defaultAction) alert.addTextField { (textField) in textField.delegate = self } self.present(alert, animated: true) 실행 결과

iOS/코드조각 2022.08.21

[iOS, Swift] UIAlertController 경고창 예제

iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다. let alert = UIAlertController(title: "Simple", message: "Simple Message with Cancel and OK", preferredStyle: .alert) alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { _ in print("Cancel") })) alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in print("OK") })) self.present(alert, animated: true) 실행 ..

iOS/코드조각 2022.08.21

[iOS, Swift] UIView 기능 모음

[iOS, Swift] UIView 흔들림 효과 주기 [iOS, Swift] UIView 흔들림 효과 주기 iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다. extension UIView { func shake() { let animation = CAKeyframeAnimation(keyPath: "transform.translation.x") animation.timingFunction = CAMe.. bksesame.tistory.com [iOS, Swift] UIView 애니메이션 효과 [iOS, Swift] UIView 애니메이션 효과 iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다. let view = UIView..

iOS/iOS 2022.08.21

[iOS, Swift] UIImageView 기능 모음

[iOS, Swift] UIImageView 원으로 만들기 [iOS, Swift] UIImageView 원으로 만들기 iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다. imageView.layer.cornerRadius = imageView.frame.height / 2 imageView.layer.shouldRasterize = true imageView.clipsToBounds = true bksesame.tistory.com [iOS, Swift] ImageView ContentMode 특징 (Scale to Fill, Aspect Fit, Aspect Fill) [iOS, Swift] ImageView ContentMode 특징 (Scale to Fill,..

iOS/iOS 2022.08.21

[iOS, Swift] UIView 위치 및 사이즈 설정 (extension)

iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다. extension UIView { var x: CGFloat { get { return self.frame.origin.x } set { self.frame = CGRect(x: newValue, y: self.frame.origin.y, width: self.frame.size.width, height: self.frame.size.height) } } var y: CGFloat { get { return self.frame.origin.y } set { self.frame = CGRect(x: self.frame.origin.x, y: newValue, width: self.frame.size.width, he..

iOS/코드조각 2022.08.21

[iOS, Swift] UIView 흔들림 효과 주기

iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다. extension UIView { func shake() { let animation = CAKeyframeAnimation(keyPath: "transform.translation.x") animation.timingFunction = CAMediaTimingFunction(name: .linear) animation.duration = 0.6 animation.values = [-10.0, 10.0, -7.0, 7.0, -5.0, 5.0, 0.0] layer.add(animation, forKey: "shake") } } 좌우로 흔들리는 애니메이션 효과를 줄 수 있다.

iOS/코드조각 2022.08.21
반응형