-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3주차] 기본과제 구현 #9
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
뷰모델까지 짜긴 어려워서 일단은 MVC로 구현했습니다! MyPage 관련 파일만 봐주시면 감사하겠습니당
|
||
private let isLastSection: Bool | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 bool을 통해 마지막 섹션이라면 로그아웃 버튼을 아니라면 구분선을 띄움!
|
||
private lazy var vStackView: UIStackView = { | ||
let stackView = UIStackView(arrangedSubviews: [seperatorView,logoutButton]) | ||
stackView.axis = .vertical | ||
stackView.alignment = .center | ||
return stackView | ||
}() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
구분선과 로그아웃버튼은 스택뷰로 묶여져있고 둘중 하나를 히든 처리하면 스택뷰 사이즈도 작아짐
vStackView.snp.makeConstraints { | ||
$0.top.bottom.equalToSuperview().inset(20) | ||
$0.leading.trailing.equalToSuperview() | ||
} | ||
|
||
seperatorView.snp.makeConstraints { | ||
$0.width.equalToSuperview().inset(10) | ||
$0.height.equalTo(1) | ||
} | ||
|
||
logoutButton.snp.makeConstraints { | ||
$0.width.equalToSuperview() | ||
$0.height.equalTo(54) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스택뷰는 슈퍼뷰와 제약조건 잡고
구분선과 로그아웃버튼은 크기만 지정
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { | ||
switch section { | ||
case 0: | ||
return MyPageSettingFooterView(isLastSection: false).intrinsicContentSize.height | ||
case 1: | ||
return MyPageSettingFooterView(isLastSection: true).intrinsicContentSize.height | ||
default: | ||
return 0 | ||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
푸터 높이는 해당 푸터인스턴스 만든 후 인스턴스의 intrincsSize 계산하여 반환
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { | ||
|
||
switch section { | ||
case 0: | ||
return MyPageSettingFooterView(isLastSection: false) | ||
case 1: | ||
return MyPageSettingFooterView(isLastSection: true) | ||
default: | ||
return nil | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
마지막 섹션일때만 인자에 true를 넣어준다
private let nameButton: UIButton = { | ||
var config = UIButton.Configuration.filled() | ||
config.buttonSize = .small | ||
config.baseBackgroundColor = .clear | ||
config.image = UIImage(systemName: "pencil") | ||
config.imagePlacement = .trailing | ||
config.imagePadding = 5 | ||
config.imageColorTransformer = .init({ _ in | ||
return .tvingLightGray | ||
}) | ||
var subtitleAttr = AttributedString.init("장석우") | ||
subtitleAttr.font = .tvingSemiBold(ofSize: 23) | ||
config.attributedTitle = subtitleAttr | ||
|
||
let button = UIButton(configuration: config) | ||
|
||
return button | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
버튼 configuration 사용하기 넘 어렵..ㄷ
private var currentNode : Node<String>? { | ||
didSet{ mainTitle = currentNode?.data } | ||
} | ||
private var dataLinkedList = LinkedList<String>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
삽입삭제가 자주 필요한 곳에 썻다면 굳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
캐로우셀에 적용시키려니까 너무 어렵네여으 ㅠㅜ 그냥 배열로 할까봐요...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
복잡한 제 코드 보다가 잠시 쉬러 왔습니다.. 깔끔한 코드 힐링이네요.. 😵💫🌿 석우님 코드 너무 궁금해요~~~
memberShipStackView.addArrangedSubViews(memberShipImageView, | ||
memberShipLabel, | ||
myMemberShipButton) | ||
|
||
cashStackView.addArrangedSubViews(cashImageView, | ||
cashLabel, | ||
myCashButton) | ||
|
||
darkStackView.addArrangedSubViews(memberShipStackView, cashStackView) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 보통 stackView를 생성할 때 lazy var
로 선언한 뒤 생성할 때 .addArrangedSubViews
를 하는 편인데, 혹시 이렇게 하면 조금 비효율적일까요..? 요렇게 밖에 빠져 있는 걸 보니까 급 의문이 드네오.. 🤔🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 처음에 조이님 방법처럼 작성했다가 다른분들이 제 코드를 볼때, 뷰의 계층구조는 모두 layout()
함수에 모아져 있는 것이 가독성 측면에 좋아보일 것 같아서 밖으로 뺐습니다.
|
||
rightImageView.snp.makeConstraints { | ||
$0.centerY.equalToSuperview() | ||
$0.trailing.equalToSuperview().offset(-5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이것도 그냥 궁금해진건데 코드에서 이런 식으로 inset
과 offset
을 혼합해서 쓰면 가독성이 조금 떨어질까요?
circleProfileButton.snp.makeConstraints{
$0.top.equalToSuperview().offset(55)
$0.trailing.equalToSuperview().inset(11)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 가독성보단 offset과 inset의 역할이 뭔지에 따라 offset으로 할지 inset으로 할지 결정하는데여
한 Constraints만 수정할때는 offset
을 사용하고
하나이상의 constraints를 조정할 때는 inset
을 사용합니다.
circleProfileButton.snp.makeConstraints{
$0.top.equalToSuperview().offset(55)
$0.trailing.equalToSuperview().offset(-11)
}
circleProfileButton.snp.makeConstraints{
$0.top.equalToSuperview().offset(55)
$0.leading.trailing.equalToSuperview().inset(11)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오호.. 감사합니다! 제가 혹시 잘못 사용하고 있나 싶어서 질문드렸어요..ㅎㅎ
let view = UIScrollView() | ||
view.bounces = false | ||
view.showsVerticalScrollIndicator = false | ||
view.contentInsetAdjustmentBehavior = .never |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오.. 검색해봤는데 이해가 잘 안돼요.. ㅜ,ㅜ 혹시 설명 부탁드려도 될까요?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스크롤뷰를 어떻게 구현했는지가 궁금하신걸까여 아니면
bounces
,
showsVerticalScrollIndicator
,
contentInsetAdjustmentBehavior
가 궁금하신건가엽?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
앗 범위를 잘못 설정했네요.. 🥲 contentInsetAdjustmentBehavior
요 속성이 무슨 역할을 하는지 궁금했어요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scrollview가 top을 superview와 일치시켜도 safearea를 넘지 못하는 오류해결하려고 추가했어욥!
🔥 Pull requests
🌴 작업한 브랜치
✅ 작업한 내용
❗️PR Point
📸 스크린샷