
[UIKit] : Autolayout, SnapKit 사용해보기
2022. 9. 20. 12:52
iOS/UIKit
Swift 는 View들의 위치를 Layout으로 정해준다. 이때 Layout을 상수로 지정해주면 기기를 바꾸는 경우 원하는 상황이 연출되지 않을 것이다! iOS 기기마다 화면 View의 크기가 다르기 때문이다 -> 이를 해결하기 위해 AutoLayout 을 사용해보자! 1. 기존의 frame을 사용한 코드를 먼저 보자 import UIKit import Foundation class ViewController: UIViewController{ private let testView : UIView = { let testView = UIView() testView.backgroundColor = .blue return testView }() override func viewDidLoad() { super...
[UIKit] : CocoaPods 설치, 라이브러리 (SnapKit + Then)사용하기
2022. 9. 20. 12:45
iOS/UIKit
SnapKit, Then 등 외부라이브러리를 사용하기 위해 CocoaPods 을 설치해보자!! https://cocoapods.org CocoaPods.org CocoaPods is built with Ruby and is installable with the default Ruby available on macOS. We recommend you use the default ruby. Using the default Ruby install can require you to use sudo when installing gems. Further installation instructions are in the g cocoapods.org 위 링크로 접속하면 $ sudo gem install cocoapod..
[UIKit] : UITextField 키보드 올리고 내리기
2022. 9. 11. 12:43
iOS/UIKit
UITextField에 텍스트를 입력할 때 사용하는 키보드를 올리고, 내려보자 방법은 간단하다 becomeFirstResponder 와 resignFirstResponder를 사용하면 된다. 버튼을 눌렀을 때 키보드를 올리고 내리는 함수를 작성해보자 override func viewDidLoad() { super.viewDidLoad() view.addSubview(textField) view.addSubview(showButton) view.addSubview(hideButton) showButton.addTarget(self, action: #selector(didTapShowButton), for: .touchUpInside) hideButton.addTarget(self, action: #sele..

[UIKit] : TextField 값 실시간으로 가져오기
2022. 9. 11. 12:08
iOS/UIKit
ID 혹은 Password 를 실시간으로 검사하는 기능을 원한다면 이 글을 참고해보자! 우선 텍스트 필드를 띄우고, TextField 속 Text 의 확인을 위한 Label을 만들어준다. class ViewController: UIViewController{ private let textField : UITextField = { let textField = UITextField() textField.placeholder = "문자열 입력" textField.backgroundColor = .cyan return textField }() private let checkLabel : UILabel = { let label = UILabel() label.backgroundColor = .gray label...

[UIKit] : CollectionView Header 만들기 - (UICollectionReusableView)
2022. 9. 2. 16:49
iOS/UIKit
Collection View에서 UICollectionReusableView를 사용하여 header를 만들어보자. 전 글에서 CollectionView 를 만들었으니 코드를 이어서 작성해보자! 참고 : https://seorin-yy.tistory.com/19 [Swift] : CollectionView 생성, Cell 등록하기 정말 많이 사용되는 CollectionView 를 띄워보자. Collection View 를 생성하기 전에 먼저 CollectionView 에서 사용될 Cell 을 만들어보자 UICollectionViewCell를 상속받는 Cell을 생성해주자. 그리고 알 수.. seorin-yy.tistory.com UICollectionReusableView를 사용하여 Header를 만들게 ..

[UIKit] : CollectionView 생성, Cell 등록하기
2022. 9. 2. 16:26
iOS/UIKit
정말 많이 사용되는 CollectionView 를 띄워보자. Collection View 를 생성하기 전에 먼저 CollectionView 에서 사용될 Cell 을 만들어보자 UICollectionViewCell를 상속받는 Cell을 생성해주자. 그리고 알 수 있게 배경화면을 파란색으로 설정해주자 class CollectionViewCell: UICollectionViewCell { static let identifier = "CollectionViewCell" override init(frame: CGRect) { super.init(frame: frame) //Cell에서는 View대신 ContentView를 사용한다 contentView.backgroundColor = .blue } required..