Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
x.y.z Release Notes (yyyy-MM-dd)
=============================================================

2.1.0 Release Notes (2026-05-27)
=============================================================

### Added

* Re-added the `minimumWidth` property, now including the horizontal `contentInset` padding, to help external layout systems size the button around its content.

### Fixed

* An issue where the title label could wrap onto two lines after `sizeToFit` was called against an already-narrow frame.

2.0.0 Release Notes (2026-01-22)
=============================================================

Expand Down
2 changes: 1 addition & 1 deletion TORoundedButton.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TORoundedButton'
s.version = '2.0.0'
s.version = '2.1.0'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'A high-performance button control with rounded corners for iOS.'
s.homepage = 'https://github.com/TimOliver/TORoundedButton'
Expand Down
5 changes: 5 additions & 0 deletions TORoundedButton/TORoundedButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ IB_DESIGNABLE @interface TORoundedButton : UIControl
/// A callback handler triggered each time the button is tapped.
@property (nonatomic, copy) void (^tappedHandler)(void);

/// The smallest width this button can be while still fitting its content on a single
/// line, including the horizontal `contentInset` padding. Useful for external layout
/// systems (such as alert controllers) sizing themselves around the button.
@property (nonatomic, readonly) CGFloat minimumWidth;

/// Create a new instance of a button that can be further configured with either text or custom subviews.
/// The size will be 288 points wide, and 50 tall by default.
- (instancetype)init;
Expand Down
13 changes: 13 additions & 0 deletions TORoundedButton/TORoundedButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ - (void)layoutSubviews {

// Lay out the title label
if (!_titleLabel) { return; }
// Seed the label with the available content width first; otherwise a stale,
// too-narrow frame makes sizeToFit wrap the text onto multiple lines even
// when there is plenty of horizontal room.
CGRect labelFrame = _titleLabel.frame;
labelFrame.size = contentBounds.size;
_titleLabel.frame = labelFrame;
[_titleLabel sizeToFit];
_titleLabel.center = (CGPoint){
.x = CGRectGetMidX(_contentView.bounds),
Expand Down Expand Up @@ -330,6 +336,13 @@ - (CGSize)sizeThatFits:(CGSize)size {
return newSize;
}

- (CGFloat)minimumWidth {
// Measure at a large but finite size so the content lays out on a single line
// without tripping Core Text overflow handling (which a literal CGFLOAT_MAX can,
// once sizeThatFits: subtracts the horizontal padding from it).
return [self sizeThatFits:(CGSize){1.0e6, 1.0e6}].width;
}

#pragma mark - Interaction -

- (void)_didTouchDownInside {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand Down
Loading
Loading