AKSegmentedControl.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // AKSegmentedControl.h
  3. //
  4. // Copyright (c) 2013 Ali Karagoz (http://alikaragoz.net)
  5. //
  6. // Permission is hereby granted, free of charge, to any person obtaining a copy
  7. // of this software and associated documentation files (the "Software"), to deal
  8. // in the Software without restriction, including without limitation the rights
  9. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. // copies of the Software, and to permit persons to whom the Software is
  11. // furnished to do so, subject to the following conditions:
  12. //
  13. // The above copyright notice and this permission notice shall be included in
  14. // all copies or substantial portions of the Software.
  15. //
  16. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. // THE SOFTWARE.
  23. #import <UIKit/UIKit.h>
  24. /** Behavior of when touching the each buttons. */
  25. typedef NS_ENUM(NSUInteger, AKSegmentedControlMode) {
  26. /** Upon touching the buttons, they will remain selected. */
  27. AKSegmentedControlModeSticky,
  28. /** Button like mode. Upon touching the buttons, they will transition from selected to normal mode. */
  29. AKSegmentedControlModeButton,
  30. /** Multi selectionable. It is possible to select multiple buttons at once. */
  31. AKSegmentedControlModeMultipleSelectionable,
  32. };
  33. @interface AKSegmentedControl : UIControl
  34. /** Array containing pointers to the `UIButton` of the segmented control. */
  35. @property (nonatomic, strong, readwrite) NSArray *buttonsArray;
  36. /** Image used to cover the background of the whole segmented control. */
  37. @property (nonatomic, strong, readwrite) UIImage *backgroundImage;
  38. /** Image used to represent the vertical separator between each button of the segmented control. */
  39. @property (nonatomic, strong, readwrite) UIImage *separatorImage;
  40. /** list of indexed currently selected. */
  41. @property (nonatomic, strong, readwrite) NSIndexSet *selectedIndexes;
  42. /** Insets of the whole segmented control view. */
  43. @property (nonatomic, assign, readwrite) UIEdgeInsets contentEdgeInsets;
  44. /** Button behavior used upon the user touch. */
  45. @property (nonatomic, assign, readwrite) AKSegmentedControlMode segmentedControlMode;
  46. /**
  47. * Manually selects an index of the segmented control.
  48. *
  49. * @param index Index of the button you want to be selected.
  50. */
  51. - (void)setSelectedIndex:(NSUInteger)index;
  52. /**
  53. * Manually sets the selected indexes when using the `AKSegmentedControlModeMultipleSelectionable` mode.
  54. *
  55. * @param indexSet Set of the indexes you want to be selected.
  56. * @param expandSelection When set this keeps previously selected indexes.
  57. */
  58. - (void)setSelectedIndexes:(NSIndexSet *)indexSet byExpandingSelection:(BOOL)expandSelection;
  59. -(void)initButtonWithTitleandImage:(NSArray *)buttonTitleandImage;
  60. @end