- MGUDropdownButton
- Written in Objective-C, Swift and Objective-C compatability
- SKUDropdownButton
- Written in Swift
MGUDropdownButton
,SKUDropdownButton
는NSPopUpButton
(macOS) 의 기능을 구현 및 확장한 iOS 용 커스텀 Dropdown Button- MTS 프로젝트를 진행하면서 증권사 앱에서 사용되는 Dropdown Button에 대한 요구사항이 있어서 제작함.
- 커스텀 사이즈 가능(
intrinsicContentSize
도 가지고 있으므로 autolayout으로 position만으로도 설정 가능) - Auto direction 지원
- 기본적으로 popup으로 등장하는 컨텐츠는 버튼의 아래쪽 등장한다.
- 그러나 만약 컨텐츠가 아래쪽에 등장했을 때, 가시권에서 벗어나는 경우라면 팝업 직전에 내부적으로 계산하여 위치를 자동 조정된다.
- Auto Height 지원
- popup될 컨텐츠 리스트가 대량이어서 여유공간보다 클 경우 자동으로 컨텐츠 컨테이너가 조정되고 스크롤 가능하게된다.
- 회전 시 위치 재조정 지원
- 화면 회전 시, 이미 표시된 팝오버는 현재 화면 상태에 맞게 위치가 자동으로 재조정되거나, 필요에 따라 자동으로 사라지게 하는 것을 선택할 수 있다.
@property (nonatomic, getter=isDismissOnRotation) BOOL dismissOnRotation;
- Style presets 지원
- 5가지의 presets
- Presets에 추가적 커스텀 가능
- Text alignment 설정가능 -
TextDropdownCell
일때- Place holder text alignment를 설정가능
- Content text alignment를 설정가능
- MGUDropdownButton
- Written in Objective-C, Swift and Objective-C compatability
- SKUDropdownButton
- Written in Swift
- SKUDropdownButton (Written in Swift), MGUDropdownButton (Written in Objective-C, Swift and Objective-C compatability)
- MTS 프로젝트를 진행하면서 증권사 앱에서 사용되는 Dropdown Button에 대한 요구사항이 있어서 제작함.
SKUDropdownButton - line | SKUDropdownButton - text | SKUDropdownButton - dash | SKUDropdownButton - image | SKUDropdownButton - fill type |
---|---|---|---|---|
- SKUDropSegControl (Written in swift)
- MTS 프로젝트를 진행하면서 증권사 앱에서 사용되는 Dropdown SegmentedControl에 대한 요구사항이 있어서 제작함.
- MGUDropSegControl (Written in Objective-C, Swift and Objective-C compatability)
SKUDropSegControl |
---|
Built-in configuration
Text | Image | Dash | Line | fill type |
---|---|---|---|---|
Swift
let dropdownButton = SKUDropdownButton()
dropdownButton.cellClass = SKUTextDropdownCell.self
dropdownButton.dropdownData = ["전봉색상", "전값대비", "보합색"]
dropdownButton.selectedIndex = 0
dropdownButton.dismissOnRotation = false // 회전 시 안사라지게 할 수 있다.
dropdownButton.placeHolderTextAlignment = .right
dropdownButton.textAlignment = .left
dropdownButton.addTarget(self, action: #selector(dropdownBtnValueChanged(_:)), for: .valueChanged)
contentView.addSubview(dropdownButton)
dropdownButton.skhPinCenterToSuperviewCenterWithFixSize(CGSize(width: 90.0, height: 28.0))
Objective-C
self.dropdownButton = [MGUDropdownButton new];
self.dropdownButton.cellClass = [MGUTextDropdownCell class];
self.dropdownButton.dropdownData = @[@"전봉색상", @"전값대비", @"보합색"];
self.dropdownButton.dismissOnRotation = NO; // 회전 시 안사라지게 할 수 있다.
self.dropdownButton.selectedIndex = 0;
self.dropdownButton.placeHolderTextAlignment = NSTextAlignmentRight;
self.dropdownButton.textAlignment = NSTextAlignmentLeft;
[self.dropdownButton addTarget:self action:@selector(dropdownBtnValueChanged:) forControlEvents:UIControlEventValueChanged];
[self.contentView addSubview:self.dropdownButton];
[self.dropdownButton mgrPinCenterToSuperviewCenterWithFixSize:CGSizeMake(90.0, 28.0)];
- 회전 시 위치 재조정 지원
- 화면 회전 시, 이미 표시된 팝오버는 현재 화면 상태에 맞게 위치가 자동으로 재조정되거나, 필요에 따라 자동으로 사라지게 하는 것을 선택할 수 있다.
@property (nonatomic, getter=isDismissOnRotation) BOOL dismissOnRotation; self.dropdownButton.dismissOnRotation = NO; // 회전 시 팝업된 컨텐츠의 위치 재조정
default | self.dropdownButton.dismissOnRotation = NO; |
---|---|
sonkoni(손관현), [email protected]
This project is released under the MIT License. See LICENSE for more information.