Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23189] iOS: Cannot change the width and height of Titanium.UI.Switch

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2016-08-28T23:06:21.000+0000
Affected Version/sRelease 5.3.0, Release 5.2.2
Fix Version/sn/a
ComponentsiOS
Labelsqe-5.3.0
ReporterWilson Luu
AssigneeEric Merriman
Created2016-04-11T20:53:23.000+0000
Updated2017-03-24T18:01:52.000+0000

Description

*Details:* On iOS, you cannot change the height or width (dp, percents, or absolute values) of Titanium.UI.Switch. *This is not reproducible on Android i.e. you can change the height and width.* *Steps to reproduce:*

Create a default Alloy app

In index.xml, add the following code:

<Alloy>
	<Window class="container">
		<Label id="label" onClick="doClick">Hello, World</Label>
		<Switch id="Switch_1"/>
	</Window>
</Alloy>

In index.tss, add the following code:

".container": {
	backgroundColor:"white"
}

"Label": {
	width: Ti.UI.SIZE,
	height: Ti.UI.SIZE,
	color: "#000"
}

"#label": {
	font: {
		fontSize: 12
	}
}

// change the height and width to use absolute values, dp, or other percentages
"#Switch_1": {
	"backgroundColor": "#000000",
	"height": "19.28%",
	"width": "30.80%",
	"left": "39.60%",
	"top": "60.80%"
}

Install app to device

*Actual:* The switch control is not resized; see attachments. *Expected:* The switch control should be resized.

Attachments

FileDateSize
android.png2016-04-11T20:52:39.000+000069636
ios.png2016-04-11T20:52:39.000+000023003

Comments

  1. Hans Knöchel 2016-04-11

    Hey [~wluu], so you expect the "wrapping view" of the switch to resized, am I correct?
  2. Wilson Luu 2016-04-11

    [~hansknoechel], Yes.
  3. Angel Petkov 2016-04-14

    The UISwitch is not designed to be customized , you cannot re-size it without transforming it, which isn't actual resizing but just stretching the object. From what i can see on the pictures its neither re-sizble on android just the View which holds the switch is being re-sized. On iOS since the switch is a very simple widget we don't give it a wrapper view , we directly add it to the parent.
  4. Hans Knöchel 2016-08-28

    As Angel stated above, the switch is not supposed to be resizable. And since we add it directly to prevent another wrapper-view, this should be the way to go. If we still want to resize the wrapper that can be achieved by wrapping it and size that view. Please consider to resolve, thanks!
  5. Lee Morris 2017-03-24

    Closing ticket as invalid with reference to the above comments.

JSON Source