Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] [iOS] Button, ImageButton and RadioButton have a minimum height of 44px #11130

Open
velocitysystems opened this issue Jun 19, 2020 · 0 comments
Labels
a/imagebutton e/4 🕓 4 in-progress This issue has an associated pull request that may resolve it! p/iOS 🍎 t/bug 🐛
Milestone

Comments

@velocitysystems
Copy link
Contributor

velocitysystems commented Jun 19, 2020

Description

Button, ImageButton and RadioButton have a minimum height of 44px on iOS.
This value is hard-coded into the renderer and forces a minimum height.

Note: No minimum height is forced on other platforms including Android or UWP.

Steps to Reproduce

  1. Create an ImageButton
  2. Use an image with a height less than 44px or set a HeightRequest.

Expected Behavior

The button should renderer the same across all platforms.

Actual Behavior

The button image is not rendered properly. Why? See code excerpt below:

public class ImageButtonRenderer : ViewRenderer<ImageButton, UIButton>, IImageVisualElementRenderer
{
bool _isDisposed;
// This looks like it should be a const under iOS Classic,
// but that doesn't work under iOS
// ReSharper disable once BuiltInTypeReferenceStyle
// Under iOS Classic Resharper wants to suggest this use the built-in type ref
// but under iOS that suggestion won't work
readonly nfloat _minimumButtonHeight = 44; // Apple docs
[Preserve(Conditional = true)]
public ImageButtonRenderer() : base()
{
ButtonElementManager.Init(this);
BorderElementManager.Init(this);
ImageElementManager.Init(this);
}
public override SizeF SizeThatFits(SizeF size)
{
var result = base.SizeThatFits(size);
if (result.Height < _minimumButtonHeight)
{
result.Height = _minimumButtonHeight;
}
return result;
}

Basic Information

  • Version with issue: All XF versions
  • Last known good version: N/A

Workaround

Create a custom ImageButtonRenderer and override the SizeThatFits method:

/// <inheritdoc/>
public override CGSize SizeThatFits(CGSize size)
{
    return Control.SizeThatFits(size);
}

If approved, I am happy to create a PR to fix this issue.

@velocitysystems velocitysystems added s/unverified New report that has yet to be verified t/bug 🐛 labels Jun 19, 2020
@pauldipietro pauldipietro added this to New in Triage Jun 19, 2020
@samhouts samhouts added e/4 🕓 4 and removed s/unverified New report that has yet to be verified labels Jun 26, 2020
@samhouts samhouts moved this from New to Ready For Work in Triage Jun 26, 2020
@samhouts samhouts added this to To do in iOS Ready For Work Jun 26, 2020
@samhouts samhouts removed this from Ready For Work in Triage Jun 26, 2020
@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Jul 20, 2020
@samhouts samhouts added this to In Progress in 4.7.0 Jul 20, 2020
@samhouts samhouts moved this from To do to In progress in iOS Ready For Work Jul 20, 2020
@samhouts samhouts removed this from In Progress in 4.7.0 Jul 23, 2020
@velocitysystems velocitysystems changed the title [Bug] [iOS] ImageButton has a minimum height of 44px [Bug] [iOS] Controls have a minimum height of 44px Jul 24, 2020
@velocitysystems velocitysystems changed the title [Bug] [iOS] Controls have a minimum height of 44px [Bug] [iOS] Button, ImageButton and RadioButton have a minimum height of 44px Jul 24, 2020
@samhouts samhouts added this to In Progress in .NET MAUI Backlog Jul 30, 2020
@samhouts samhouts removed this from In Progress in .NET MAUI Backlog Aug 4, 2020
@samhouts samhouts added this to In Progress in vNext+1 (5.0.0) Aug 11, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@PureWeen PureWeen added this to To do in v5.0.1 via automation Nov 2, 2020
@PureWeen PureWeen removed this from In Progress in vNext+1 (5.0.0) Nov 2, 2020
@PureWeen PureWeen modified the milestones: 5.0.0, 5.0.1 Nov 2, 2020
@samhouts samhouts added this to In Progress in vNext+1 (5.0.0) Nov 2, 2020
@PureWeen PureWeen removed this from In Progress in vNext+1 (5.0.0) Nov 5, 2020
@samhouts samhouts added this to In Progress in vNext+1 (5.0.0) Nov 5, 2020
@PureWeen PureWeen removed this from In Progress in vNext+1 (5.0.0) Nov 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/imagebutton e/4 🕓 4 in-progress This issue has an associated pull request that may resolve it! p/iOS 🍎 t/bug 🐛
Projects
iOS Ready For Work
  
In progress
v5.0.1
To do
Development

Successfully merging a pull request may close this issue.

4 participants