Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ x.y.z Release Notes (yyyy-MM-dd)

### Added

* A `delegate` property to receive tap events for the button where delegates are preferred over blocks.
* An `isTranslucent` property (and a `blurStyle` property) that replaces the background of buttons from a solid color to a blurred background.
* A `contentView` property to enable adding custom view content to buttons.
* `sizeToFit` and `sizeThatFits:` methods to allow automatic sizing of buttons around their content.
Expand Down
13 changes: 13 additions & 0 deletions TORoundedButton/TORoundedButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,22 @@

NS_ASSUME_NONNULL_BEGIN

@class TORoundedButton;

@protocol TORoundedButtonDelegate <NSObject>

/// Called when the user taps on the associated button.
/// - Parameter button: The button object that was tapped.
- (void)roundedButtonDidTap:(TORoundedButton *)button;

@end

NS_SWIFT_NAME(RoundedButton)
IB_DESIGNABLE @interface TORoundedButton : UIControl

/// A delegate object that can receive tap events from this button.
@property (nonatomic, weak) id<TORoundedButtonDelegate> delegate;

/// The radius of the corners of this button (Default is 12.0f).
@property (nonatomic, assign) IBInspectable CGFloat cornerRadius;

Expand Down
3 changes: 2 additions & 1 deletion TORoundedButton/TORoundedButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@ - (void)_didTouchUpInside {
// Send the semantic button action for apps relying on this action
[self sendActionsForControlEvents:UIControlEventPrimaryActionTriggered];

// Trigger the block if it has been set
// Broadcast the tap event to all subscribed objects.
if (self.tappedHandler) { self.tappedHandler(); }
[_delegate roundedButtonDidTap:self];
}

- (void)_didDragOutside {
Expand Down