diff --git a/TORoundedButton/TORoundedButton.h b/TORoundedButton/TORoundedButton.h index c8ff07e..0291e07 100644 --- a/TORoundedButton/TORoundedButton.h +++ b/TORoundedButton/TORoundedButton.h @@ -36,7 +36,7 @@ IB_DESIGNABLE @interface TORoundedButton : UIControl /** The attributed string used in the label of this button. See `UILabel.attributedText` documentation for full details (Default is nil) */ @property (nonatomic, copy, nullable) NSAttributedString *attributedText; -/** The radius of the corners of this button (Default is 10.0f) */ +/** The radius of the corners of this button (Default is 12.0f) */ @property (nonatomic, assign) IBInspectable CGFloat cornerRadius; /** The color of the text in this button (Default is white) */ @@ -45,7 +45,7 @@ IB_DESIGNABLE @interface TORoundedButton : UIControl /** When tapped, the level of transparency that the text label animates to. (Defaults to 0.5f) */ @property (nonatomic, assign) IBInspectable CGFloat tappedTextAlpha; -/** The font of the text in the button (Default is size 19 Bold) */ +/** The font of the text in the button (Default is size UIFontTextStyleBody with bold) */ @property (nonatomic, strong) UIFont *textFont; /** Because IB cannot handle fonts, this can alternatively be used to set the font size. (Default is off with 0.0) */ diff --git a/TORoundedButton/TORoundedButton.m b/TORoundedButton/TORoundedButton.m index 46de619..59321c7 100644 --- a/TORoundedButton/TORoundedButton.m +++ b/TORoundedButton/TORoundedButton.m @@ -24,12 +24,6 @@ @interface TORoundedButton () -/** Marked whenever the graphical components of the button need to be recalculated */ -@property (nonatomic, assign) BOOL isDirty; - -/** When clear, Core Animation clipping is used instead of a bitmap to produce transparency */ -@property (nonatomic, assign) BOOL isClear; - /** Hold on to a global state for whether we are tapped or not because the state can change before blocks complete */ @property (nonatomic, assign) BOOL isTapped; @@ -40,16 +34,7 @@ @interface TORoundedButton () @property (nonatomic, strong) UILabel *titleLabel; /** An image view that displays the rounded box behind the button text */ -@property (nonatomic, strong) UIImageView *backgroundImageView; - -/** The dynamically generated rounded box image that is applied to the image view */ -@property (nonatomic, strong, nullable) UIImage *backgroundImage; - -/** A resizable image that optionally shows when the button is tapped */ -@property (nonatomic, strong, nullable) UIImage *tappedBackgroundImage; - -/** Because this view is always clear, intercept and store the intended background color */ -@property (nonatomic, strong, nullable) UIColor *buttonBackgroundColor; +@property (nonatomic, strong) UIView *backgroundView; @end @@ -100,15 +85,11 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder - (void)roundedButtonCommonInit { // Default properties (Make sure they're not overriding IB) - _cornerRadius = (_cornerRadius > FLT_EPSILON) ?: 10.0f; + _cornerRadius = (_cornerRadius > FLT_EPSILON) ?: 12.0f; _tappedTextAlpha = (_tappedTextAlpha > FLT_EPSILON) ?: 1.0f; _tapAnimationDuration = (_tapAnimationDuration > FLT_EPSILON) ?: 0.4f; _tappedButtonScale = (_tappedButtonScale > FLT_EPSILON) ?: 0.97f; _tappedTintColorBrightnessOffset = !TO_ROUNDED_BUTTON_FLOAT_IS_ZERO(_tappedTintColorBrightnessOffset) ?: -0.1f; - _isDirty = YES; - - if (!_buttonBackgroundColor) { _buttonBackgroundColor = [UIColor whiteColor]; } - super.backgroundColor = [UIColor clearColor]; // Set the tapped tint color if we've set to dynamically calculate it [self updateTappedTintColorForTintColor]; @@ -122,16 +103,29 @@ - (void)roundedButtonCommonInit [self addSubview:self.containerView]; // Create the image view which will show the button background - self.backgroundImageView = [[UIImageView alloc] initWithFrame:self.bounds]; - self.backgroundImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - self.backgroundImageView.clipsToBounds = YES; - [self.containerView addSubview:self.backgroundImageView]; + self.backgroundView = [[UIView alloc] initWithFrame:self.bounds]; + self.backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + self.backgroundView.backgroundColor = self.tintColor; + self.backgroundView.layer.cornerRadius = _cornerRadius; +#ifdef __IPHONE_13_0 + if (@available(iOS 13.0, *)) { self.backgroundView.layer.cornerCurve = kCACornerCurveContinuous; } +#endif + [self.containerView addSubview:self.backgroundView]; // Create the title label that will display the button text + UIFont *buttonFont = [UIFont preferredFontForTextStyle:UIFontTextStyleBody]; + buttonFont = [UIFont systemFontOfSize:buttonFont.pointSize weight:UIFontWeightBold]; + if (@available(iOS 11.0, *)) { + // Apply resizable button metrics to font + UIFontMetrics *metrics = [[UIFontMetrics alloc] initForTextStyle:UIFontTextStyleBody]; + buttonFont = [metrics scaledFontForFont:buttonFont]; + } + self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; self.titleLabel.textAlignment = NSTextAlignmentCenter; self.titleLabel.textColor = [UIColor whiteColor]; - self.titleLabel.font = [UIFont systemFontOfSize:19.0f weight:UIFontWeightBold]; + self.titleLabel.font = buttonFont; + self.titleLabel.adjustsFontForContentSizeCategory = YES; self.titleLabel.backgroundColor = self.tintColor; self.titleLabel.text = @"Button"; [self.containerView addSubview:self.titleLabel]; @@ -141,9 +135,6 @@ - (void)roundedButtonCommonInit [self addTarget:self action:@selector(didTouchUpInside) forControlEvents:UIControlEventTouchUpInside]; [self addTarget:self action:@selector(didDragOutside) forControlEvents:UIControlEventTouchDragExit|UIControlEventTouchCancel]; [self addTarget:self action:@selector(didDragInside) forControlEvents:UIControlEventTouchDragEnter]; - - // Configure views for the current state - [self configureBackgroundView]; } #pragma mark - View Displaying - @@ -152,78 +143,23 @@ - (void)layoutSubviews { [super layoutSubviews]; - // Regenerate the images if they are dirty and we need them - if (!self.isClear && self.isDirty) { - [self generateOpaqueImages]; - self.isDirty = NO; - } - // Configure the button text [self.titleLabel sizeToFit]; self.titleLabel.center = self.containerView.center; self.titleLabel.frame = CGRectIntegral(self.titleLabel.frame); } -- (void)generateOpaqueImages -{ - // Double check we have the correct tint color set - [self updateTappedTintColorForTintColor]; - - // Generate any images we need - self.backgroundImage = [[self class] buttonImageWithBackgroundColor:self.buttonBackgroundColor - foregroundColor:self.tintColor - cornerRadius:self.cornerRadius]; - - // Attach this new image to the background view - self.backgroundImageView.image = self.backgroundImage; - - // If we've set a tapped color, generate an image for that one too - if (self.tappedTintColor) { - self.tappedBackgroundImage = [[self class] buttonImageWithBackgroundColor:self.buttonBackgroundColor - foregroundColor:self.tappedTintColor - cornerRadius:self.cornerRadius]; - } - else { - self.tappedBackgroundImage = nil; - } -} - -- (void)configureBackgroundView -{ - // Configure the image view depending on the state - if (self.isClear) { [self configureImageViewForClearDisplay]; } - else { [self configureImageViewForOpaqueDisplay]; } -} - -- (void)configureImageViewForOpaqueDisplay -{ - // Configure the background image view for opaque drawing - self.backgroundImageView.image = self.backgroundImage; - self.backgroundImageView.backgroundColor = nil; - - // Reset ourselves from potential clipping - self.containerView.layer.masksToBounds = NO; - self.containerView.layer.cornerRadius = 0.0f; -} - -- (void)configureImageViewForClearDisplay -{ - // Clear out any images on the image view - self.backgroundImageView.image = nil; - - // Configure the background image view for transparent drawing - self.backgroundImageView.backgroundColor = self.tintColor; - - // Configure ourselves for clipping the views - self.containerView.layer.masksToBounds = YES; - self.containerView.layer.cornerRadius = self.cornerRadius; -} - - (void)tintColorDidChange { [super tintColorDidChange]; self.titleLabel.backgroundColor = self.isTapped ? [UIColor clearColor] : self.tintColor; - self.isDirty = YES; + self.backgroundView.backgroundColor = self.tintColor; + [self setNeedsLayout]; +} + +- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection +{ + [super traitCollectionDidChange:previousTraitCollection]; [self setNeedsLayout]; } @@ -258,8 +194,10 @@ - (void)didTouchUpInside [self setBackgroundColorTappedAnimated:YES]; [self setButtonScaledTappedAnimated:YES]; + // Send the semantic button action for apps relying on this action [self sendActionsForControlEvents:UIControlEventPrimaryActionTriggered]; + // Trigger the block if it has been set if (self.tappedHandler) { self.tappedHandler(); } } @@ -296,79 +234,28 @@ - (void)setBackgroundColorTappedAnimated:(BOOL)animated // ----------------------------------------------------- - // For transparent buttons, just animate the tint color - if (self.isClear) { - void (^animationBlock)(void) = ^{ - self.backgroundImageView.backgroundColor = self.isTapped ? self.tappedTintColor : self.tintColor; - }; - - void (^completionBlock)(BOOL) = ^(BOOL completed){ - if (completed == NO) { return; } - updateTitleOpacity(); - }; - - if (!animated) { - animationBlock(); - completionBlock(YES); - } - else { - self.titleLabel.backgroundColor = [UIColor clearColor]; - [UIView animateWithDuration:self.tapAnimationDuration - delay:0.0f - options:UIViewAnimationOptionBeginFromCurrentState - animations:animationBlock - completion:completionBlock]; - } - - return; - } + void (^animationBlock)(void) = ^{ + self.backgroundView.backgroundColor = self.isTapped ? self.tappedTintColor : self.tintColor; + }; - // ----------------------------------------------------- + void (^completionBlock)(BOOL) = ^(BOOL completed){ + if (completed == NO) { return; } + updateTitleOpacity(); + }; - // Define a single key for reffering to cross fade the image contents - NSString *animateContentsKey = @"animateContents"; - if (!animated) { - [self.backgroundImageView.layer removeAnimationForKey:animateContentsKey]; - self.backgroundImageView.image = self.isTapped ? self.tappedBackgroundImage : self.backgroundImage; - updateTitleOpacity(); - return; + animationBlock(); + completionBlock(YES); } - - // For opaque buttons, perform a Core Animation cross fade animation - UIImage *fromImage = self.isTapped ? self.backgroundImage : self.tappedBackgroundImage; - UIImage *toImage = self.isTapped ? self.tappedBackgroundImage : self.backgroundImage; - - // If we quickly move between states before the animation completes, capture the progress - // we were at, so we can apply it as the new starting point - id presentationContents = nil; - CABasicAnimation *previousAnimation = [self.backgroundImageView.layer animationForKey:animateContentsKey]; - if (previousAnimation) { - presentationContents = self.backgroundImageView.layer.presentationLayer.contents; - [self.backgroundImageView.layer removeAnimationForKey:animateContentsKey]; + else { + self.titleLabel.backgroundColor = [UIColor clearColor]; + [UIView animateWithDuration:self.tapAnimationDuration + delay:0.0f + options:UIViewAnimationOptionBeginFromCurrentState + animations:animationBlock + completion:completionBlock]; } - // Force the label to be clear before any animations start - self.titleLabel.backgroundColor = [UIColor clearColor]; - - [CATransaction begin]; - - // When the animation is complete, set the label back to opaque - [CATransaction setCompletionBlock:^{ - // If another animation was queued after this one, don't update the opacity in this block - if ([self.backgroundImageView.layer animationForKey:animateContentsKey]) { return; } - updateTitleOpacity(); - }]; - - // Perform the crossfade animation - CABasicAnimation *crossFade = [CABasicAnimation animationWithKeyPath:@"contents"]; - crossFade.duration = self.tapAnimationDuration; - crossFade.fromValue = presentationContents ?: (id)fromImage.CGImage; - crossFade.toValue = (id)toImage.CGImage; - [self.backgroundImageView.layer addAnimation:crossFade forKey:animateContentsKey]; - self.backgroundImageView.image = toImage; - - [CATransaction commit]; } - (void)setLabelAlphaTappedAnimated:(BOOL)animated @@ -469,21 +356,12 @@ - (void)setTextPointSize:(CGFloat)textPointSize [self setNeedsLayout]; } -- (void)setBackgroundColor:(UIColor *)backgroundColor -{ - if (backgroundColor == _buttonBackgroundColor) { return; } - _buttonBackgroundColor = backgroundColor; - _isDirty = YES; - _isClear = ![[self class] isOpaqueColor:backgroundColor]; - [self configureBackgroundView]; - [self setNeedsLayout]; -} - - (void)setTintColor:(UIColor *)tintColor { [super setTintColor:tintColor]; - _isDirty = YES; [self updateTappedTintColorForTintColor]; + self.backgroundView.backgroundColor = tintColor; + self.titleLabel.backgroundColor = tintColor; [self setNeedsLayout]; } @@ -491,7 +369,6 @@ - (void)setTappedTintColor:(UIColor *)tappedTintColor { if (_tappedTintColor == tappedTintColor) { return; } _tappedTintColor = tappedTintColor; - _isDirty = YES; _tappedTintColorBrightnessOffset = 0.0f; [self setNeedsLayout]; } @@ -505,7 +382,6 @@ - (void)setTappedTintColorBrightnessOffset:(CGFloat)tappedTintColorBrightnessOff } _tappedTintColorBrightnessOffset = tappedTintColorBrightnessOffset; - _isDirty = YES; [self updateTappedTintColorForTintColor]; [self setNeedsLayout]; } @@ -518,54 +394,17 @@ - (void)setCornerRadius:(CGFloat)cornerRadius } _cornerRadius = cornerRadius; - _isDirty = YES; + self.backgroundView.layer.cornerRadius = _cornerRadius; [self setNeedsLayout]; } - (void)setEnabled:(BOOL)enabled { [super setEnabled:enabled]; - self.containerView.alpha = enabled ? 1 : 0.4; } #pragma mark - Graphics Handling - -+ (BOOL)isOpaqueColor:(UIColor *)color -{ - // If the background color's _alpha_ is anything other than 1.0, it's not opaque. ;) - CGFloat a = 0; - [color getRed:NULL green:NULL blue:NULL alpha:&a]; - return a >= (1.0f - FLT_EPSILON); -} - -+ (UIImage *)buttonImageWithBackgroundColor:(UIColor *)backgroundColor - foregroundColor:(UIColor *)foregroundColor - cornerRadius:(CGFloat)cornerRadius -{ - - CGFloat dimensionSize = (cornerRadius * 2.0f) + 2.0f; - CGSize size = (CGSize){dimensionSize, dimensionSize}; - - UIGraphicsImageRendererFormat *format = [[UIGraphicsImageRendererFormat alloc] init]; - format.opaque = YES; - - UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:size format:format]; - UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext *rendererContext) { - if (format.opaque) { - UIBezierPath *backgroundPath = [UIBezierPath bezierPathWithRect:(CGRect){CGPointZero, size}]; - [backgroundColor setFill]; - [backgroundPath fill]; - } - - //// Rectangle Drawing - UIBezierPath *foregroundPath = [UIBezierPath bezierPathWithRoundedRect:(CGRect){CGPointZero, size} cornerRadius:cornerRadius]; - [foregroundColor setFill]; - [foregroundPath fill]; - }]; - - UIEdgeInsets insets = UIEdgeInsetsMake(cornerRadius, cornerRadius, cornerRadius, cornerRadius); - return [image resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch]; -} + (UIColor *)brightnessAdjustedColorWithColor:(UIColor *)color amount:(CGFloat)amount { diff --git a/TORoundedButtonExample.xcodeproj/project.pbxproj b/TORoundedButtonExample.xcodeproj/project.pbxproj index f4cbbfb..d6d81a9 100644 --- a/TORoundedButtonExample.xcodeproj/project.pbxproj +++ b/TORoundedButtonExample.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 220F9AB222784FD4001862A7 /* TORoundedButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 220F9AB022784FD4001862A7 /* TORoundedButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 220F9AB522784FD4001862A7 /* TORoundedButton.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 220F9AAE22784FD4001862A7 /* TORoundedButton.framework */; }; 220F9AB622784FD4001862A7 /* TORoundedButton.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 220F9AAE22784FD4001862A7 /* TORoundedButton.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 220F9ABC22784FF5001862A7 /* TORoundedButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 22700662226CA35D003492CB /* TORoundedButton.m */; }; @@ -55,8 +54,6 @@ /* Begin PBXFileReference section */ 220F9AAE22784FD4001862A7 /* TORoundedButton.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = TORoundedButton.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 220F9AB022784FD4001862A7 /* TORoundedButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TORoundedButton.h; sourceTree = ""; }; - 220F9AB122784FD4001862A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 220F9ABE2278AA0B001862A7 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 22700639226CA24D003492CB /* TORoundedButtonExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TORoundedButtonExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 2270063C226CA24D003492CB /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -102,15 +99,6 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 220F9AAF22784FD4001862A7 /* TORoundedButton */ = { - isa = PBXGroup; - children = ( - 220F9AB022784FD4001862A7 /* TORoundedButton.h */, - 220F9AB122784FD4001862A7 /* Info.plist */, - ); - path = TORoundedButton; - sourceTree = ""; - }; 220F9ABD2278AA0B001862A7 /* TORoundedButtonFramework */ = { isa = PBXGroup; children = ( @@ -126,7 +114,6 @@ 2270063B226CA24D003492CB /* TORoundedButtonExample */, 220F9ABD2278AA0B001862A7 /* TORoundedButtonFramework */, 22700654226CA24E003492CB /* TORoundedButtonExampleTests */, - 220F9AAF22784FD4001862A7 /* TORoundedButton */, 2270063A226CA24D003492CB /* Products */, ); sourceTree = ""; @@ -183,16 +170,15 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 220F9AB222784FD4001862A7 /* TORoundedButton.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ - 220F9AAD22784FD4001862A7 /* TORoundedButton */ = { + 220F9AAD22784FD4001862A7 /* TORoundedButtonFramework */ = { isa = PBXNativeTarget; - buildConfigurationList = 220F9AB922784FD4001862A7 /* Build configuration list for PBXNativeTarget "TORoundedButton" */; + buildConfigurationList = 220F9AB922784FD4001862A7 /* Build configuration list for PBXNativeTarget "TORoundedButtonFramework" */; buildPhases = ( 220F9AA922784FD4001862A7 /* Headers */, 220F9AAA22784FD4001862A7 /* Sources */, @@ -203,7 +189,7 @@ ); dependencies = ( ); - name = TORoundedButton; + name = TORoundedButtonFramework; productName = TORoundedButton; productReference = 220F9AAE22784FD4001862A7 /* TORoundedButton.framework */; productType = "com.apple.product-type.framework"; @@ -281,7 +267,7 @@ targets = ( 22700638226CA24D003492CB /* TORoundedButtonExample */, 22700650226CA24E003492CB /* TORoundedButtonExampleTests */, - 220F9AAD22784FD4001862A7 /* TORoundedButton */, + 220F9AAD22784FD4001862A7 /* TORoundedButtonFramework */, ); }; /* End PBXProject section */ @@ -347,7 +333,7 @@ /* Begin PBXTargetDependency section */ 220F9AB422784FD4001862A7 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = 220F9AAD22784FD4001862A7 /* TORoundedButton */; + target = 220F9AAD22784FD4001862A7 /* TORoundedButtonFramework */; targetProxy = 220F9AB322784FD4001862A7 /* PBXContainerItemProxy */; }; 22700653226CA24E003492CB /* PBXTargetDependency */ = { @@ -397,7 +383,7 @@ ); MACH_O_TYPE = staticlib; PRODUCT_BUNDLE_IDENTIFIER = dev.tim.TORoundedButton; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + PRODUCT_NAME = TORoundedButton; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; @@ -425,7 +411,7 @@ ); MACH_O_TYPE = staticlib; PRODUCT_BUNDLE_IDENTIFIER = dev.tim.TORoundedButton; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + PRODUCT_NAME = TORoundedButton; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; @@ -485,6 +471,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 10.0; + LD_RUNPATH_SEARCH_PATHS = "$(CONFIGURATION_BUILD_DIR)"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -538,6 +525,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 10.0; + LD_RUNPATH_SEARCH_PATHS = "$(CONFIGURATION_BUILD_DIR)"; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -555,6 +543,7 @@ LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", + "$(CONFIGURATION_BUILD_DIR)", ); PRODUCT_BUNDLE_IDENTIFIER = dev.tim.TORoundedButtonExample; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -572,6 +561,7 @@ LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", + "$(CONFIGURATION_BUILD_DIR)", ); PRODUCT_BUNDLE_IDENTIFIER = dev.tim.TORoundedButtonExample; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -620,7 +610,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 220F9AB922784FD4001862A7 /* Build configuration list for PBXNativeTarget "TORoundedButton" */ = { + 220F9AB922784FD4001862A7 /* Build configuration list for PBXNativeTarget "TORoundedButtonFramework" */ = { isa = XCConfigurationList; buildConfigurations = ( 220F9AB722784FD4001862A7 /* Debug */, diff --git a/TORoundedButtonExample.xcodeproj/xcshareddata/xcschemes/TORoundedButtonFramework.xcscheme b/TORoundedButtonExample.xcodeproj/xcshareddata/xcschemes/TORoundedButtonFramework.xcscheme index 05012b4..108f833 100644 --- a/TORoundedButtonExample.xcodeproj/xcshareddata/xcschemes/TORoundedButtonFramework.xcscheme +++ b/TORoundedButtonExample.xcodeproj/xcshareddata/xcschemes/TORoundedButtonFramework.xcscheme @@ -16,7 +16,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "220F9AAD22784FD4001862A7" BuildableName = "TORoundedButton.framework" - BlueprintName = "TORoundedButton" + BlueprintName = "TORoundedButtonFramework" ReferencedContainer = "container:TORoundedButtonExample.xcodeproj"> @@ -47,7 +47,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "220F9AAD22784FD4001862A7" BuildableName = "TORoundedButton.framework" - BlueprintName = "TORoundedButton" + BlueprintName = "TORoundedButtonFramework" ReferencedContainer = "container:TORoundedButtonExample.xcodeproj"> @@ -65,7 +65,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "220F9AAD22784FD4001862A7" BuildableName = "TORoundedButton.framework" - BlueprintName = "TORoundedButton" + BlueprintName = "TORoundedButtonFramework" ReferencedContainer = "container:TORoundedButtonExample.xcodeproj"> diff --git a/TORoundedButtonExample/Base.lproj/Main.storyboard b/TORoundedButtonExample/Base.lproj/Main.storyboard index 94f6ce9..92141e4 100644 --- a/TORoundedButtonExample/Base.lproj/Main.storyboard +++ b/TORoundedButtonExample/Base.lproj/Main.storyboard @@ -1,6 +1,6 @@ - + @@ -15,155 +15,47 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - - - + + + + - - - - + + - + - - - diff --git a/TORoundedButtonExample/ViewController.h b/TORoundedButtonExample/ViewController.h index 6da03e7..3cec2ad 100644 --- a/TORoundedButtonExample/ViewController.h +++ b/TORoundedButtonExample/ViewController.h @@ -13,11 +13,8 @@ NS_ASSUME_NONNULL_BEGIN @interface ViewController : UIViewController -@property (weak, nonatomic) IBOutlet TORoundedButton *opaqueButton; -@property (weak, nonatomic) IBOutlet TORoundedButton *clearButton; - -@property (weak, nonatomic) IBOutlet UILabel *opaqueTappedLabel; -@property (weak, nonatomic) IBOutlet UILabel *transparentTappedLabel; +@property (weak, nonatomic) IBOutlet TORoundedButton *button; +@property (weak, nonatomic) IBOutlet UILabel *tappedLabel; @end diff --git a/TORoundedButtonExample/ViewController.m b/TORoundedButtonExample/ViewController.m index 26bd316..007386e 100644 --- a/TORoundedButtonExample/ViewController.m +++ b/TORoundedButtonExample/ViewController.m @@ -17,19 +17,15 @@ @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; - self.opaqueTappedLabel.alpha = 0.0f; - self.transparentTappedLabel.alpha = 0.0f; + // Hide the tapped label + self.tappedLabel.alpha = 0.0f; // Uncomment this line for an attributed string example - // self.clearButton.attributedText = [[self class] makeExampleAttributedString]; + // self.button.attributedText = [[self class] makeExampleAttributedString]; __weak typeof(self) weakSelf = self; - self.opaqueButton.tappedHandler = ^{ - [weakSelf playFadeAnimationOnView:weakSelf.opaqueTappedLabel]; - }; - - self.clearButton.tappedHandler = ^{ - [weakSelf playFadeAnimationOnView:weakSelf.transparentTappedLabel]; + self.button.tappedHandler = ^{ + [weakSelf playFadeAnimationOnView:weakSelf.tappedLabel]; }; } diff --git a/TORoundedButtonFramework/Info.plist b/TORoundedButtonFramework/Info.plist index 43fde39..a0df466 100644 --- a/TORoundedButtonFramework/Info.plist +++ b/TORoundedButtonFramework/Info.plist @@ -11,7 +11,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - $(PRODUCT_NAME) + TORoundedButton CFBundlePackageType FMWK CFBundleShortVersionString