segmented-control icon indicating copy to clipboard operation
segmented-control copied to clipboard

apportionsSegmentWidthsByContent

Open DenisDov opened this issue 1 year ago • 2 comments

Is there any possibility to use apportionsSegmentWidthsByContent from UISegmentedControl to adjust segment widths based on their content widths?

DenisDov avatar Aug 16 '24 08:08 DenisDov

+1 To this. It would especially be useful when there is limited horizontal space and some labels are shorter than others.

SCR-20241220-irm

iankberry avatar Dec 20 '24 18:12 iankberry

+1, for now we added with the patch below

diff --git a/index.d.ts b/index.d.ts
index aa8d5f54d135e16952d630084571e872329dc26b..4b4bf423288413dbbc17b0db33deabf7e2c79179 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -116,6 +116,8 @@ export interface SegmentedControlProps extends ViewProps {
    * Style properties for the Animated.View component
    */
   sliderStyle?: ViewStyle;
+
+  apportionsSegmentWidthsByContent?: boolean;
 }

 /**
diff --git a/ios/RNCSegmentedControlManager.m b/ios/RNCSegmentedControlManager.m
index 553bc1f35d40fa196fb70dfff3e3a82924262cc6..70081e2c01a87a72cc6eea177fd0531106baded0 100644
--- a/ios/RNCSegmentedControlManager.m
+++ b/ios/RNCSegmentedControlManager.m
@@ -25,6 +25,7 @@ RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor)
 RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor)
 RCT_EXPORT_VIEW_PROPERTY(momentary, BOOL)
 RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL)
+RCT_EXPORT_VIEW_PROPERTY(apportionsSegmentWidthsByContent, BOOL)
 RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
 RCT_EXPORT_VIEW_PROPERTY(appearance, NSString)
 RCT_EXPORT_VIEW_PROPERTY(testIDS, NSArray)

enchorb avatar Aug 14 '25 18:08 enchorb