uiswitch

Change color of UISwitch appwise

落花浮王杯 提交于 2019-12-04 16:11:10
问题 I am using UISwitch in iOS 3 to make a switch element in my app. It has default color set to blue, but I want to change its color to brown. How can I choose a different color for the UISwitch element in iOS 3? How can I choose a different color for the UISwitch element in a modern iOS app (iOS 5+)? 回答1: For a modern iOS XX version skip the answer as it has zero relevance lately. Still here? In iOS 3. You can't. But you know… people are landing here because of rank, and comments containing

How to change UISwitch default color for OFF state?

巧了我就是萌 提交于 2019-12-04 08:49:42
I want to change the color of onTintColor in the UISwitch for the off State. The switch is in tableview and switch is made programmatically. [settingsSwitch setBackgroundColor:[UIColor whiteColor]]; [settingsSwitch setTintColor:[UIColor whiteColor]]; [settingsSwitch setThumbTintColor:[UIColor redColor]]; [settingsSwitch setOnTintColor:[UIColor colorWithRed:138/256.0 green:9/256.0 blue:18/256.0 alpha:1]]; This is the result i get when i set the background color white. And without background i get red color which is the color of my cell. and this is the result i want, when switch is on the

How do I retrieve UITableView row number of a UISwitch?

不羁岁月 提交于 2019-12-04 01:33:04
问题 I have tried several approaches posted here, but I cannot get my table full of switches to return an index value for the cell of the changed switch. I am creating the view containing the table programmatically (no xib). TableSandboxAppDelegate.m I instantiate the view controller in didFinishLaunchingWithOptions: with: ... TableSandboxViewController *sandboxViewController = [[TableSandboxViewController alloc] init]; [[self window] setRootViewController:sandboxViewController]; ...

Detecting a change in UISwitch

醉酒当歌 提交于 2019-12-04 00:02:20
This sounds trivial but I'm noticing some weirdness. I've wired up a handler for the Value Changed event of a UISwitch. What I would expect is that each time the handler is called the value of the switch would change. But that's actually not always the case. If you press the switch rapidly on/off the handler can get called consecutively with the SAME state for the switch (in my specific application this is an issue). So I'm wondering if anyone else has noticed this behavior and has figured out a good solution. -(void) createSwitch { self.searchExistSearchNewSwitch = [[UISwitch alloc]

How to get the value of a UISwitch?

霸气de小男生 提交于 2019-12-03 23:53:02
I am a newbie iOS programmer and I have a problem. I currently work on iOS Core Data and my problem is that I want to insert data into a boolean attribute to a database by taking the value of a UISwitch . The problem is that i don't know what it the method i have to call (e.g .text does the same thing but for UITextField). I have done a small google search but no results. Here is some code: [newContact setValue:howMany.text forKey:@"quantity"]; [newContact setValue:important.??? forKey:@"important"]; howmany is a textfield, important is a UISwitch Joel Kravets To save it [newContact setObject:

iOS - Moving a UITextField to a Different Position when a UIView Moves

冷暖自知 提交于 2019-12-03 20:35:35
I have a main UIView which moves up by means of a switch. I have this working and there is no problem there. Now the UIView when down, takes up about half of the Screen and when it is pushed up it shows the bottom 40px. In the UIView when it is down it has a UITextField and it sits somewhere in the middle. When the UIView is pushed up I want that UITextField to move to sit within those 40px, so that it always accessible. This is the code I got for the UIView to move: -(IBAction)mainview:(id)sender{ if (uiSwitch.on) { label.text = @"Push Up View"; [UIView beginAnimations:@"animateView" context

Save and Load UISwitch state

你离开我真会死。 提交于 2019-12-03 14:12:44
问题 I want to save the swtich state and load it when the program restarted. [[NSUserDefaults standardUserDefaults] setBool:switchControl.on forKey:@"switch"]; [[NSUserDefaults standardUserDefaults] synchronize]; This is the saving part BOOL test= [[NSUserDefaults standardUserDefaults] boolForKey:@"switch"]; NSLog(@"%@",test?@"YES":@"NO"); if(test == YES) [switchControl setOn:YES animated:YES]; else [switchControl setOn:NO animated:YES]; This is the part that is need to be set the switch to its

Switch in UIAlert Controller programmatically

喜夏-厌秋 提交于 2019-12-03 13:42:53
问题 I am creating an registration dialog in swift with 3 text field and one Switch and I successfully add three text field two the Alert. The following code shows the same. let alertController = UIAlertController(title: "Register", message: "", preferredStyle: .Alert) let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) in // ... exit(0) } alertController.addAction(cancelAction) let OKAction = UIAlertAction(title: "Sign UP", style: .Default) { (action) in // ... let name0

Changing UISwitch width and height

亡梦爱人 提交于 2019-12-03 10:50:21
问题 I am trying to change the default height and width of a UISwitch element in iOS, but unsuccessfully. Can you change the default height and width of a UISwitch element? Should the element be created programmatically? 回答1: I tested the theory and it appears that you can use a scale transform to increase the size of the UISwitch UISwitch *aSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(120, 120, 51, 31)]; aSwitch.transform = CGAffineTransformMakeScale(2.0, 2.0); [self.view addSubview

Change color of UISwitch appwise

谁说我不能喝 提交于 2019-12-03 10:08:50
I am using UISwitch in iOS 3 to make a switch element in my app. It has default color set to blue, but I want to change its color to brown. How can I choose a different color for the UISwitch element in iOS 3? How can I choose a different color for the UISwitch element in a modern iOS app (iOS 5+)? dlamblin For a modern iOS XX version skip the answer as it has zero relevance lately. Still here? In iOS 3. You can't. But you know… people are landing here because of rank, and comments containing other versions and stuff so… The fifth iOS release now allows a documented way of doing this: with the