Skip to content
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

Custom Ticks #9

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8f4f62e
Adding methods for dynamic tick marks
Jan 17, 2018
a674c6d
Tick object, tick layout constraints.
Feb 15, 2018
d9bb120
Cleanup of unused code.
Feb 18, 2018
d649c67
Trying another approach.
Feb 20, 2018
adce665
tick spacing is working
Feb 23, 2018
da80763
Final cleanup
Feb 23, 2018
c77a69d
Updating the readme
Feb 23, 2018
8aa87a5
fixing heading formatting
Feb 23, 2018
a162d61
Added comment to clarify refreshView param
Feb 23, 2018
750d43d
Resolving minor code comments
Feb 23, 2018
244fbb6
Update project.pbxproj
thejeff77 Feb 23, 2018
619bd5c
Changing to NSUInteger
Feb 23, 2018
fd911a1
Merge branch 'master' of https:/thejeff77/HUMSlider
Feb 23, 2018
6607181
Updating defaults to documented values.
Feb 23, 2018
89f9b91
oops
Feb 23, 2018
ce407bf
reverting default size changes
Mar 5, 2018
0212379
added logic to squeeze the ticks to the slider
Mar 5, 2018
6b3b8ef
Made the ticks animate and squeeze to the slider.
Mar 5, 2018
2e71a84
Added a remove all method
Mar 12, 2018
8b19404
Added App Icon full view.
Apr 13, 2018
d8ec346
fixing main thread warnings
Jun 24, 2018
38336e1
Removed unnecessary methods
Jun 25, 2018
bef5dfc
Fixed bugs switching between the two slider types
Jul 2, 2018
2324ead
Removed copyright as it interferes with the MIT license. Added commen…
Jul 5, 2018
534837e
Cleanup and bugfixing
Jul 5, 2018
e486cdf
Touched up the readme
Jul 5, 2018
9d6583e
Final cleanup and merging
Jul 5, 2018
25bc0ed
Changing double to CGFloat
Jul 5, 2018
5ebf725
using self. instead of synthesized
Jul 5, 2018
5d3858e
use BOOL not bool
Jul 5, 2018
8f0804a
Fixed index insertion error for middle constraints
Jul 6, 2018
82b4ba6
Removing global track Rect
Jul 6, 2018
519f692
Removing unused var
Jul 6, 2018
51a6e12
Fixed issue where the tick doesn't pop or show on initial addition
Aug 27, 2018
3db2dac
Real fix for a transparency issue
Aug 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions HUMSliderSample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
9BA867D31A4DF3B900121ED5 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0610;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Just Hum, LLC";
TargetAttributes = {
9BA867DA1A4DF3B900121ED5 = {
Expand Down Expand Up @@ -303,20 +303,32 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand Down Expand Up @@ -344,20 +356,31 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -376,8 +399,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = HUMSliderSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.justhum.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -387,8 +411,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = HUMSliderSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.justhum.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand All @@ -407,6 +432,7 @@
);
INFOPLIST_FILE = HUMSliderSampleTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.justhum.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HUMSliderSample.app/HUMSliderSample";
};
Expand All @@ -422,6 +448,7 @@
);
INFOPLIST_FILE = HUMSliderSampleTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.justhum.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HUMSliderSample.app/HUMSliderSample";
};
Expand Down
2 changes: 1 addition & 1 deletion HUMSliderSample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.justhum.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
2 changes: 1 addition & 1 deletion HUMSliderSampleTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.justhum.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
50 changes: 49 additions & 1 deletion Library/HUMSlider.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ typedef NS_ENUM(NSUInteger, HUMSliderSide) {
HUMSliderSideRight
};

@interface Tick : NSObject
- (id)initWithPosition:(CGFloat)position;
@property CGFloat position; //Number between 0 and 1 indicating the slider position of the tick.
@end

/**
* A slider which pops up ticks and saturates/desaturates images when the user adjusts
* a slider for better feedback to the user about their adjustment.
Expand All @@ -23,6 +28,8 @@ typedef NS_ENUM(NSUInteger, HUMSliderSide) {
@interface HUMSlider : UISlider

#pragma mark - Ticks
///Tick positions, specified as "Tick" objects with values between 0 and 1
@property (atomic) NSMutableArray *ticks;

///The color of the ticks you wish to pop up. Defaults to dark gray.
@property (nonatomic) UIColor *tickColor;
Expand All @@ -33,6 +40,9 @@ typedef NS_ENUM(NSUInteger, HUMSliderSide) {
///How many points the tick popping should be adjusted for a custom thumbnail image to account for any space at the top (for example, to balance out a custom shadow).
@property (nonatomic) CGFloat pointAdjustmentForCustomThumb;

//Fade the ticks out to transparent when the user is not actively moving the slider.
@property (nonatomic) BOOL enableTicksTransparencyOnIdle;

#pragma mark - Images

///The color to use as the fully-saturated color on both sides. Defaults to red.
Expand All @@ -55,9 +65,39 @@ typedef NS_ENUM(NSUInteger, HUMSliderSide) {
///How long to wait between animating secondary ticks. Defaults to 0.025 seconds.
@property (nonatomic) NSTimeInterval nextTickAnimationDelay;

///Turns the custom tick feature on and off.
@property (nonatomic) BOOL customTicksEnabled;

///Ticks animate down to track line when user is not actively moving the slider.
@property (nonatomic) BOOL lowerTicksOnInactiveTouch;


#pragma mark - Setters/Getters for individual sides

/**
* Inserts a tick at a position.
* @param tick The tick with the set position between 0 and 1
* @param refreshView Will update the view this time with the added tick.
*/
- (void)addTick:(Tick*)tick willRefreshView:(BOOL)refreshView;

/**
* Refreshes the view in a custom way, in case you didn't do it for each tick addition.
*/
- (void)refreshView;

/**
* Removes the tick at the given index. .
* @param index The tick Index with the set position between 0 and 1
* @param refreshView Will update the view this time with the removed tick.
*/
- (void)removeTickAtIndex:(NSUInteger)index refreshView:(BOOL)refreshView;

/**
* Remove all of the ticks
*/
- (void)removeAllTicks;

/**
* Sets the color to use as the fully-saturated color on selected side.
*
Expand All @@ -75,7 +115,7 @@ typedef NS_ENUM(NSUInteger, HUMSliderSide) {
/**
* Sets the color to use as the desaturated color on selected side.
*
* @param saturatedColor The UIColor to use
* @param desaturatedColor The UIColor to use
* @param side The side you wish to set a desaturated color upon.
*/
- (void)setDesaturatedColor:(UIColor *)desaturatedColor forSide:(HUMSliderSide)side;
Expand All @@ -86,4 +126,12 @@ typedef NS_ENUM(NSUInteger, HUMSliderSide) {
*/
- (UIColor *)desaturatedColorForSide:(HUMSliderSide)side;

/**
* Method to manually update the tick heights to the thumb image as
* if the touch was tracking. This comes in handy if the slider will
* move separate from user input, like for song playback or other non-
* user driven input.
*/
- (void)updateTickHeights;

@end
Loading