123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- //
- // IQActionSheetPickerView.h
- // https://github.com/hackiftekhar/IQActionSheetPickerView
- // Copyright (c) 2013-14 Iftekhar Qurashi.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // THE SOFTWARE.
- #import <UIKit/UIKit.h>
- #import "IQActionSheetToolbar.h"
- #if !(__has_feature(objc_instancetype))
- #define instancetype id
- #endif
- /**
- Action Sheet style settings.
-
- `IQActionSheetPickerStyleTextPicker`
- Show pickerView with provided text data.
-
- `IQActionSheetPickerStyleDatePicker`
- Show UIDatePicker.
- */
- typedef NS_ENUM(NSUInteger, IQActionSheetPickerStyle) {
-
- IQActionSheetPickerStyleTextPicker,
-
- IQActionSheetPickerStyleDatePicker,
-
- IQActionSheetPickerStyleDateTimePicker,
-
- IQActionSheetPickerStyleTimePicker,
- };
- /// These keys are used to set text attributes for both `Cancel` and `Done` toolbar buttons.
- /// Identifies an attributed string of the toolbar button title for normal state.
- extern NSString * _Nonnull const kIQActionSheetAttributesForNormalStateKey;
- /// Identifies an attributed string of the toolbar button title for highlighted state.
- extern NSString * _Nonnull const kIQActionSheetAttributesForHighlightedStateKey;
- @class IQActionSheetPickerView;
- /*!
- ActionSheetPickerView delegate.
- */
- @protocol IQActionSheetPickerViewDelegate <NSObject>
- @optional
- - (void)actionSheetPickerView:(nonnull IQActionSheetPickerView *)pickerView didSelectTitles:(nonnull NSArray<NSString*>*)titles;
- - (void)actionSheetPickerView:(nonnull IQActionSheetPickerView *)pickerView didSelectDate:(nonnull NSDate*)date;
- - (void)actionSheetPickerView:(nonnull IQActionSheetPickerView *)pickerView didChangeRow:(NSInteger)row inComponent:(NSInteger)component;
- - (void)actionSheetPickerViewDidCancel:(nonnull IQActionSheetPickerView *)pickerView;
- - (void)actionSheetPickerViewWillCancel:(nonnull IQActionSheetPickerView *)pickerView;
- @end
- /*!
- ActionSheet style UIPickerView
- */
- @interface IQActionSheetPickerView : UIControl
- /*!
- Initialization method with a title for toolbar and a callback delegate
- */
- - (nonnull instancetype)initWithTitle:(nullable NSString *)title delegate:(nullable id<IQActionSheetPickerViewDelegate>)delegate;
- /*!
- delegate(weak reference) object to inform about the selected values in pickerView. Delegate method will be called on Done click.
- */
- @property(nullable, nonatomic, weak) id<IQActionSheetPickerViewDelegate> delegate;
- /*!
- actionSheetPickerStyle to show in picker. Default is IQActionSheetPickerStyleTextPicker.
- */
- @property(nonatomic, assign) IQActionSheetPickerStyle actionSheetPickerStyle; //
- @property(nonatomic,strong) IQActionSheetToolbar * _Nullable actionToolbar;
- /*!
- Color for toolBar
- */
- @property(nullable, nonatomic, strong) UIColor *toolbarTintColor UI_APPEARANCE_SELECTOR;
- /*!
- Color for buttons
- */
- @property(nullable, nonatomic, strong) UIColor *toolbarButtonColor UI_APPEARANCE_SELECTOR;
- /*!
- A dictionary containing the attributed strings of the cancel button for normal and highlighted states.
- */
- @property(nullable, nonatomic, strong) NSDictionary<NSString*,id> *cancelButtonAttributes UI_APPEARANCE_SELECTOR;
- /*!
- A dictionary containing the attributed strings of the done button for normal and highlighted states.
- */
- @property(nullable, nonatomic, strong) NSDictionary<NSString*,id> *doneButtonAttributes UI_APPEARANCE_SELECTOR;
- ///----------------------
- /// @name Show / Hide
- ///----------------------
- /*!
- Show picker view with slide up animation.
- */
- -(void)show;
- /*!
- Show picker view with slide up animation, completion block will be called on animation completion.
- */
- -(void)showWithCompletion:(nullable void (^)(void))completion;
- /*!
- Dismiss picker view with slide down animation.
- */
- -(void)dismiss;
- /*!
- Dismiss picker view with slide down animation, completion block will be called on animation completion.
- */
- -(void)dismissWithCompletion:(nullable void (^)(void))completion;
- ///-----------------------------------------
- /// @name IQActionSheetPickerStyleTextPicker
- ///-----------------------------------------
- /*!
- selected titles for each component. Please use [ NSArray of NSString ] format. (Not Animated)
- */
- @property(nullable, nonatomic, strong) NSArray<NSString*> *selectedTitles;
- /*!
- set selected titles for each component. Please use [ NSArray of NSString ] format.
- */
- -(void)setSelectedTitles:(nonnull NSArray<NSString*> *)selectedTitles animated:(BOOL)animated;
- /*!
- Titles to show for component. Please use [ NSArray(numberOfComponents) of [ NSArray of NSString ](RowValueForEachComponent)] format, even there is single row to show, For example.
- @[ @[ @"1", @"2", @"3", ], @[ @"11", @"12", @"13", ], @[ @"21", @"22", @"23", ]].
- */
- @property(nullable, nonatomic, strong) NSArray<NSArray<NSString*> *> *titlesForComponents;
- /*!
- Width to adopt for each component. Please use [NSArray of NSNumber] format. If you don't want to specify a row width then use @(0) to calculate row width automatically.
- */
- @property(nullable, nonatomic, strong) NSArray<id> *widthsForComponents;
- /*!
- Font for the UIPickerView components
- */
- @property(nullable, nonatomic, strong) UIFont *pickerComponentsFont UI_APPEARANCE_SELECTOR;
- /*!
- Background color for the `UIPickerView`
- */
- @property(nullable, nonatomic, strong) UIColor *pickerViewBackgroundColor UI_APPEARANCE_SELECTOR;
- /*!
- * Color for the UIPickerView
- */
- @property(nullable, nonatomic, strong) UIColor *pickerComponentsSelectColor UI_APPEARANCE_SELECTOR;
- @property(nullable, nonatomic, strong) UIColor *pickerComponentsColor UI_APPEARANCE_SELECTOR;
- @property(nullable, nonatomic, strong) UIColor *lineColor;
- @property(nonatomic, assign) CGSize lineSize;
- @property(nonatomic,assign)BOOL clickBackHide;
- @property(nonatomic,strong)UIColor* pickBkgColor;
- /*!
- Font for the UIToolBar title
- */
- @property(nullable, nonatomic, strong) UIFont *titleFont UI_APPEARANCE_SELECTOR;
- /*!
- * Color for the UIToolBar title
- */
- @property(nullable, nonatomic, strong) UIColor *titleColor UI_APPEARANCE_SELECTOR;
- /*!
- Select the provided index row for each component. Please use [ NSArray of NSNumber ] format for indexes. Ignore if actionSheetPickerStyle is IQActionSheetPickerStyleDatePicker.
- */
- -(void)selectIndexes:(nonnull NSArray<NSNumber*> *)indexes animated:(BOOL)animated;
- /*!
- If YES then it will force to scroll third picker component to pick equal or larger row then the first.
- */
- @property(nonatomic, assign) BOOL isRangePickerView;
- /*!
- Reload a component in pickerView.
- */
- -(void)reloadComponent:(NSInteger)component;
- /*!
- Reload all components in pickerView.
- */
- -(void)reloadAllComponents;
- ///-------------------------------------------------------------------------------------------------------------------
- /// @name IQActionSheetPickerStyleDatePicker/IQActionSheetPickerStyleDateTimePicker/IQActionSheetPickerStyleTimePicker
- ///-------------------------------------------------------------------------------------------------------------------
- /*!
- selected date. Can also be use as setter method (not animated).
- */
- @property(nullable, nonatomic, assign) NSDate *date; //get/set date.
- /*!
- set selected date.
- */
- -(void)setDate:(nonnull NSDate *)date animated:(BOOL)animated;
- /*!
- Minimum selectable date in UIDatePicker. Default is nil.
- */
- @property (nullable, nonatomic, retain) NSDate *minimumDate;
- /*!
- Maximum selectable date in UIDatePicker. Default is nil.
- */
- @property (nullable, nonatomic, retain) NSDate *maximumDate;
- @end
|