본문 바로가기
728x90

iOS/UIKit15

[Swift/UIKit] UIColor를 HexString으로 받는 Extension extension UIColor { convenience init(hexString: String) { let hex = hexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) var int = UInt64() Scanner(string: hex).scanHexInt64(&int) let alpha, red, green, blue: UInt64 switch hex.count { case 3: (alpha, red, green, blue) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0.. 2024. 7. 19.
[UIKit] App Delegate와 Scene Delegate App DelegateApp 전체가 공유하는 행동들을 관리.app delegate는 App의 실질적인 root 객체라고 할 수 있다.UIApplication 객체와 함께 동작하여 시스템과의 상호작용을 관리AppDelegate가 처리하는 작업들App의 중심이 되는 데이터 구조 초기화Scene 설정/해제App 외부로부터 전달되는 알림에 대응 (ex. 메모리부족, 백그라운드 다운로드완료 등)타겟이 특정 scene/view/viewController가 아닌 App 자체인 이벤트에 대응런치 시점에 필요한 서비스 등록 (ex. Apple Push Notification 서비스)App 상태 복구(State Restoration) 관리앱의 생명주기Not Running : 실행되지 않았거나, 시스템에 의해 종료된 상태I.. 2024. 6. 5.
[Swift/UIKit]CollectionView/TableView Cell안에 버튼넣고 이벤트주는법 간단합니다. @objc 메서드 만들고 버튼에서 addTaget 설정만 해주면 됩니다. 1. 컬렉션뷰 셀 부분에 addTaget주기 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CollectionViewCell.identifier, for: indexPath) as! CollectionViewCell cell.goBtn.addTarget(self, action: #selector(self.goBtnClicked), for: .. 2023. 10. 24.
[UIKit] translatesAutoresizingMaskIntoConstraints 왜 오토 레이아웃을 사용할 때는 translatesAutoresizingMaskIntoConstraints = false를 할까? textField.translatesAutoresizingMaskIntoConstraints = false 오토레이아웃을 잡을때, 기계적으로 해당코드를 작성하곤 했다. 그러다가 문득.. 왜 이걸 쓰는걸까? 난 왜 이걸 예제를 따라 당연하다는듯이 적었을까를 생각했다.. AutoresizingMask란, superview의 영역이 바뀔 때 하위 뷰의 크기를 어떻게 조정할지에 대한 정보를 가지고 있는 정수형 비트마스크라 한다. 해당 개념은 여러 속성을 부여하여 슈퍼뷰의 크기 변화에 따라 서브 뷰의 width, height 혹은 leading, top, trailing, bottom.. 2023. 10. 18.
헷갈리는 Auto Layout 정리하자. 0. 오토 레이아웃이란? 아이폰 SE2, 8+, X,13 15Pro 등 다양한 아이폰 화면비율에 구애받지 않고 시각적으로 동일한 화면을 구현해야하는데 이를 위한 가장 편리하고 권장되는 방법이다. https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/index.html#//apple_ref/doc/uid/TP40010853-CH7-SW1 Auto Layout Guide: Understanding Auto Layout developer.apple.com 제약 조건에 따라 뷰 계층 구조의 모든 뷰의 크기와 위치를 동적으로 계산하며, 설계에 대한 이러한 제약 기반 접근 방식을 통해 내부 및 외.. 2023. 7. 16.
[Swift/UI Kit] 'SideMenu'라이브러리 적용 (코드로만)feat.SnapKit flutter에서 drwaer메뉴가 있습니다. 옆에서 사이드바가 쇽샥쇽샥하는것이죠. 문득 스위프트에서도 그걸로 메뉴바를 대신하고싶다는 생각이 들었습니다. SideMenu라이브러리! https://github.com/jonkykong/SideMenu GitHub - jonkykong/SideMenu: Simple side/slide menu control for iOS, no code necessary! Lots of customization. Add it to your pr Simple side/slide menu control for iOS, no code necessary! Lots of customization. Add it to your project in 5 minutes or less. - G.. 2023. 7. 1.
728x90
반응형