본문 바로가기

나의 플랫폼/iOS

[iOS] 'command + =' 단축키 UILabel을 스토리 보드에 추가 하고 "시작하기" 라고 타이틀을 변경 하면 Width 사이즈는 고정이 되어 있기 때문에 위와 같이 보이게 된다. 그럼 마우스를 통해 임의로 늘리는 데요.간단한 단축키 하나라 글자에 맞게 크기가 자동으로 변경 됩니다. Command + '=' 결과는 아래와 같습니다. 참고하세요. 더보기
[iOS] @IBDesignable, @IBInspectable 활용 블로그 내용과 소스는 '꼼꼼한 재은 씨의 스위프트 실전편' 에 나오는 예제 입니다. CustomView를 만들고, 그 View를 StoryBoard에 올리면 디자인 그대로 보이지 않는다. 만약, StoryBoard에서 CustomView 형태 그대로 보고 싶다면 @IBDesignable, @IBInspectable 어노테이션을 이용하면 된다. ## @IBDesignable @IBDesignablepublic class CSStepper: UIView { public var leftBtn = UIButton(type: .system) public var rightBtn = UIButton(type: .system) public var centerLabel = UILabel() 위 소스를 보시면 UIView.. 더보기
[iOS] Custom Alert UIAlertController로 바뀐 후, 알림창을 어떻게 바꿀 수 있을까 해서 테스트를 해보았습니다. import UIKit class CustomAlertViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let alertBtn = UIButton(type: .system) alertBtn.frame = CGRect(x: 0, y: 100, width: 150, height: 30) alertBtn.setTitle("show alert", for: .normal) alertBtn.addTarget(self, action: #selector(shwoAlert(_:)), for: .touchUpInsid.. 더보기
[iOS] Get image with actionsheet private func actionSheetPicker() {let alert = UIAlertController(title: nil, message: "이미지를 가져올 곳을 선택해주세요.", preferredStyle: .actionSheet) let cameraAction = UIAlertAction(title: "카메라", style: .default, handler: {action in self.pickImage(.camera)})let albumAction = UIAlertAction(title: "저장앨범", style: .default, handler: {action in self.pickImage(.savedPhotosAlbum)})let photoLibraryAction = UIAlert.. 더보기
[iOS] Use of unresolved identifier NSAttributedStringKey TabBarItem 에서 텍스트 색상을 수정 할 때 아래와 같이 한다. 1tabBarItem.setTitleTextAttributes([NSAttributedStringKey.foregroundColor.rawValue: UIColor.gray], for: .disabled)cs 하지만, 아래 이미지 같이 에러가 발생 할 때가 있다. 머 아시겠지만, NSAttributedStringKey 가 없다는 의미 이다. https://stackoverflow.com/a/44641975위 내용을 보면 iOS 11 버전에서 사용 가능 하다고 한다. 그럼 그 아래 버전에서는 어떻게 해야 할까? 아래와 같이 사용하면 된다. 1tbItem.setTitleTextAttributes([NSForegroundColorAttri.. 더보기
[iOS] Hex Color -> UIColor func UIColorFromRGB(rgbValue: UInt) -> UIColor { return UIColor( colorLiteralRed: Float((rgbValue & 0xFF0000) >> 16) / 255.0, green: Float((rgbValue & 0x00FF00) >> 8) / 255.0, blue: Float(rgbValue & 0x0000FF) / 255.0, alpha: Float(1.0)) } 참고하세요. 더보기
[iOS] TextField 첫 영문자를 항상 소문자로 시작하는 설정법 영문자를 입력 하면 자동으로 제일 처음 문자가 대문자로 설정이 됩니다.이 부분을 항상 소문자로 나오도록 하는 방법은 아래와 같습니다. self.textField.autocapitalizationType = .none 참고하세요. 더보기
[iOS] Swift 원시 자료형 복사 아래 와 같은 소스에선 결과가 어떻게 나올까? 123456var arr = [String]() arr.append("append1") var arrCopy = arrarrCopy.append("append2")cs ["append1"] ["append1", "append2"] 이렇게 나옵니다. 왜 똑같이 ["append1", "append2"] 나오지 않고 각자 별개로 동작 할까요? 이건 Swift가 원시 자료형이 구조체로 되어 있어서새로운 변수에 넣을 경우, 새로운 데이터가 생깁니다. 그래서, reference가 아닌 value라고 보면 되겠네요. 참고하면 좋을듯 해서 공유 합니다. 더보기