Repository navigation
[iOS/Mac] Fix ImageButton background rendering with oversized CornerRadius - #39487
Dhivya-SF4094 wants to merge 54 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — 3 findings · ⚠️ 1 breaking change
Reviewed commit 47ca747.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| @@ -0,0 +1,266 @@ | |||
| using System; | |||
There was a problem hiding this comment.
[minor] Backward Compatibility and Migration - Record the observable Apple ImageButton mapper contracts in the required Behavior changes section of docs/design/HandlerResolution.md. A stock clipped 50x50 ImageButton requested at radius 100 now exposes native radius 25 after mapping, and bounds changes update it without invoking CornerRadius or Padding callbacks. Native radius assignments relinquish automatic ownership, while a later stock CornerRadius mapping claims it again; derived handlers returning an ordinary UIButton retain the old fallback. The design document contains none of these contracts or migration guidance for existing native customizations and derived handlers. The PR description instead says layout reapplies the mapping, which does not describe the implemented callback behavior.
There was a problem hiding this comment.
MAUI Autopilot · round 15
❌ Not changed. The requested behavior and migration notes belong in docs/design/HandlerResolution.md, which is outside this round’s src/-only scope.
There was a problem hiding this comment.
MAUI Autopilot · round 16
❌ Not changed. This fix round is limited to src/, so the requested design-document and PR-description updates are out of scope. I’m leaving this open for the author or a maintainer.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — 4 findings · ⚠️ 1 breaking change
Reviewed commit 6c1ee66.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
1 findings could not be attached inline; retained in run artifacts.
…pper Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…appings Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — 4 findings · ⚠️ 2 breaking changes
Reviewed commit f1f270d.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| @@ -1,5 +1,4 @@ | |||
| using System; | |||
There was a problem hiding this comment.
[minor] Backward Compatibility and Migration - Record the observable Apple ImageButton mapper contracts in the required Behavior changes section of docs/design/HandlerResolution.md. A stock clipped 50x50 ImageButton requested at radius 100 now exposes native radius 25 after mapping, and bounds changes update it without invoking CornerRadius or Padding callbacks. Native radius assignments relinquish automatic ownership, while a later stock CornerRadius mapping claims it again; derived handlers returning an ordinary UIButton retain the old fallback. The design document contains none of these contracts or migration guidance. The PR description instead says layout reapplies the mapping, which does not describe the implemented callback behavior.
There was a problem hiding this comment.
MAUI Autopilot · round 17
❌ Not changed. docs/design/HandlerResolution.md and the PR description are outside this source-only fix round, so I’m leaving this open for the maintainer.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| @@ -1,5 +1,4 @@ | |||
| using System; | |||
There was a problem hiding this comment.
[minor] Backward Compatibility and Migration - The observable Apple ImageButton mapper changes are missing from the required Behavior changes section of docs/design/HandlerResolution.md. A stock clipped 50x50 ImageButton with CornerRadius=100 now exposes native radius 25 after mapping, and bounds changes update it without invoking CornerRadius or Padding callbacks. Native radius assignments relinquish automatic ownership, while a later registered CornerRadius mapping claims it again; derived handlers returning an ordinary UIButton retain the old fallback. Document these contracts and migration guidance for existing native customizations and derived handlers, including the distinction between standalone MapCornerRadius calls and registered mappings. The PR description instead says layout reapplies the mapping, which does not describe the implemented callback behavior.
There was a problem hiding this comment.
MAUI Autopilot · round 18
❌ Not changed. The requested updates to docs/design/HandlerResolution.md and the PR description are outside this source-only round. I’m leaving this open for the author or a maintainer.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
left a comment
There was a problem hiding this comment.
Expert Review — 3 findings · ⚠️ 1 breaking change
Reviewed commit 19a6a45.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| @@ -1,5 +1,4 @@ | |||
| using System; | |||
There was a problem hiding this comment.
[minor] Backward Compatibility and Migration - Record the observable Apple ImageButton mapper contracts in the required Behavior changes section of docs/design/HandlerResolution.md. A stock clipped 50x50 ImageButton with CornerRadius=100 now exposes native radius 25 after mapping, and bounds changes update it without invoking CornerRadius or Padding callbacks. Native radius assignments relinquish automatic ownership, while a later stock registered CornerRadius mapping claims it again; standalone MapCornerRadius calls preserve native-assignment behavior, and derived handlers returning an ordinary UIButton retain the old fallback. The design document contains none of these contracts or migration guidance for existing native customizations and derived handlers. The PR description instead says layout reapplies the mapping, which does not describe the implemented callback behavior.
There was a problem hiding this comment.
MAUI Autopilot · round 19
❌ Not changed. The design document and PR description are outside this round’s src/-only scope. The ViewExtensions.UpdateBackground XML remarks now document the distinction between standalone calls and registered background mappings.
…updates Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| @@ -1,5 +1,4 @@ | |||
| using System; | |||
There was a problem hiding this comment.
[minor] Backward Compatibility and Migration - Document the changed Apple ImageButton mapper contract in the Behavior changes section of docs/design/HandlerResolution.md, with migration guidance for native customizations and derived handlers. A stock clipped 50x50 ImageButton requested at radius 100 now exposes native radius 25 after mapping, and bounds changes update it without invoking CornerRadius or Padding callbacks. Native radius assignments relinquish automatic ownership, a later registered CornerRadius mapping claims it again, standalone MapCornerRadius calls preserve native-assignment behavior, and custom handlers returning an ordinary UIButton retain the old fallback. These observable rules remain undocumented; the PR description instead says layout reapplies the mapping.
There was a problem hiding this comment.
MAUI Autopilot · round 20
❌ Not changed. The handler-resolution migration guide and PR description are outside this source-only round. The description still needs to say that native bounds observation updates effective radii without rerunning the CornerRadius or Padding mapper.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| _radiusObservation = KeyValueObservation.ObserveCornerRadius(Layer, OnRadiusChanging, beforeChange: true); | ||
| // The System button factory returns a native UIKit button, so managed | ||
| // LayoutSubviews overrides cannot be used to observe its geometry. | ||
| _boundsObservation = KeyValueObservation.ObserveBounds(Layer, UpdateCornerRadii); |
There was a problem hiding this comment.
MAUI Autopilot · round 21
❌ Not changed. This fix round cannot edit PR metadata. The implementation uses native bounds observation to update effective radii on resize without rerunning the property mappers.
left a comment
There was a problem hiding this comment.
Expert Review — 5 findings · ⚠️ 3 breaking changes
Reviewed commit 9791a5e.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
Previously reported findings were not duplicated.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
left a comment
There was a problem hiding this comment.
🔵 Needs a closer look
The PR description incorrectly says the corner-radius mapper reruns after layout and needs to document native bounds observation, shared mapper dispatch changes, and the KeepMappedGradientRadius compatibility switch.
1 open issue
Review effort: Balanced


Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue Detail
An ImageButton whose CornerRadius is larger than half of its own size does not render at all — the control stays fully transparent (it is still laid out and still receives clicks).
Root cause
On iOS, MAUI passed CornerRadius directly to the native CALayer. When the requested radius exceeded half the button’s size, it was not clamped to the available bounds. The oversized radius could also affect a background layer, leaving the ImageButton visually transparent even though it remained laid out and interactive. The radius was initially mapped before final layout bounds were available.
Description of Change
Clamp the effective radius to half the layer’s smaller dimension, and apply it to both the button layer and its background layer. Reapply the corner-radius mapping after ImageButton layout so the calculation uses final bounds. This restores the expected circular rendering for a 50x50 button with CornerRadius="100" on iOS and Mac Catalyst.
Validated the behaviour in the following platforms
Issues Fixed:
Fixes #39485
Screenshots