간단한 테이블 뷰를 만드는 방법을 친절하게 설명한 사이트입니다.
영문인 것이 함정
https://www.appcoda.com/swiftui-first-look/
2019년 12월 5일 목요일
2019년 12월 4일 수요일
swift 개발 가이드 사이트
애플에서 만든 swift 개발 가이드 페이지 이다.
매우 유용하다.
https://developer.apple.com/tutorials/swiftui/creating-and-combining-views
매우 유용하다.
https://developer.apple.com/tutorials/swiftui/creating-and-combining-views
2019년 12월 2일 월요일
[Swift] ViewController vs Contentview
Googling 을 해서 찾아보면 ViewController 에 이런 저런 구현을 하라고 되어 있는 가이드가 많았다.
근데 왠걸 내가 Project를 만드니, ViewController는 안 보이고 ContentView만 보이는 것이다.
그래서, 이게 먼가 하고 이리저리 뒤지다가 stackoverflow의 답변을 보니, 생각보다 간단하였다.
Project 생성 시에 "Swift UI"를 체크 해제하라는 것이다.
근데 왠걸 내가 Project를 만드니, ViewController는 안 보이고 ContentView만 보이는 것이다.
그래서, 이게 먼가 하고 이리저리 뒤지다가 stackoverflow의 답변을 보니, 생각보다 간단하였다.
Project 생성 시에 "Swift UI"를 체크 해제하라는 것이다.
라벨:
ContentView,
Swift,
ViewController
2019년 11월 13일 수요일
2018년 12월 2일 일요일
Swift segue를 이용한 데이터 전달
performSegue(withIdentifier: "createHabbit", sender: self)
위와 같이 performSegue를 통해 segue를 실행한다.
여러개의 segue가 있음으로 Identifier를 이용해서 수행하는 Segue를 명시한다.
그리고 아래와 같이 preparesegue에 수행할 내용을 적는다.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let destViewController = segue.destination as! ViewController
destViewController.labelText = self.sendText
print(destViewController.habbits.count)
destViewController.habbits.append(Habbit(ischecked: false, habbitName: sendText))
}
라벨:
데이터 전달,
performsegue,
prepare,
segue,
Swift
Swift Toggle Button 사용 방법
@IBAction func checkBoxTapped(_ sender: UIButton){
/*
UIView.animate(withDuration: 0.5, delay: 0.1, options: .curveLinear,
animations: {
sender.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
}) {
(success) in
sender.isSelected = !sender.isSelected
UIView.animate(withDuration: 0.5, delay: 0.1, options: .curveLinear,
animations: {
sender.transform = .identity
},completion: nil)
}
*/
if sender.isSelected {
sender.isSelected = false
} else {
sender.isSelected = true
}
}
위와 같이 sender 의 isSelected 를 사용해서 토글을 할 수 있다.
주석 처리는 애니메이션 효과를 준 것이다.
위 자료는 유튜브 동영상을 보고 만든 것이다.
출처: https://youtu.be/S6q5d3RvVY8
라벨:
button,
Swift,
toggle,
toggle button
피드 구독하기:
글 (Atom)