UIRefreshControl change color of UIActivityIndicatorView - objective-c

There is any way to change the color of the "UIActivityIndicatorView" of the UIRefreshControl??
I didn't find anything!
Thanks!!

You can do it by setting the Tint Color of the UIRefreshControl, something like this:
Objective C
[refreshControl setTintColor:[UIColor blackColor]];
Swift
refreshControl.tintColor = .black
This will also change the arrow that expands when you slide.

As the previous answer is outdated, I thought that I would just modify it to Swift 4 and share the solution (credit goes to #subharb).
refreshControl.tintColor = UIColor.white
This line of code will change the color of the UIActivityIndicatorView to whatever color you want it to be :)

Related

CustomSearchBar color differs from the one in UINavigationBar

Im using:
#define colorApp [UIColor colorWithRed:254/256.f green:64/256.f blue:89/256.f alpha:1.0]
Inside the customSearchView init:
[self setBackgroundColor:colorApp];
searchBar = [[UISearchBar alloc] initWithFrame:frame];
searchBar.barTintColor = colorApp;
[self addSubview:searchBar];
Getting the next result:
I need the searchBarTint color to be the same as the navigation. Translucent doesn't seem to make the work.
I came up with the fix soon after I posted the question.
In case anyone ever faces this problem I used
[self.searchDisplayController.searchBar setBackgroundImage:[UIImage imageNamed:#"pinkBar.png"]
forBarPosition:0
barMetrics:UIBarMetricsDefault];
It seems backgroundColor and barTintColor aren't taking colors same way as the navigation for a UISearchDisplayController since iOS 7. But adding an image with that color just resolves that.
I know it's just a quick fix but it helped me and could help others as it is a minor visual issue.

Xcode - UIDatePicker background color

My UIDatePicker's background is black (because the background for the whole screen is black probably), but I want white in the background for this UIDatePicker.
Is there any way to change the background color without subclassing it?
iOS 14 update
It looks that datePicker.backgroundColor doesn't work in iOS 14. It works. But you have to put it after preferredDatePickerStyle setting:
let picker = UIDatePicker()
if #available(iOS 13.4, *) {
picker.preferredDatePickerStyle = .wheels
}
picker.backgroundColor = .red
datePickerName.backgroundColor = [UIColor grayColor];
OBJECTIVE C
datePicker.backgroundColor = [UIColor greenColor]
SWIFT
DatePicker.backgroundColor = UIColor.blueColor()
DatePicker.setValue(UIColor.greenColor(), forKeyPath: "textColor")
DatePicker.setValue(0.8, forKeyPath: "alpha")
iOS 14 update
After iOS 14 setting background color this way
datePicker.backgroundColor = <# your bg color #>
doesn't work anymore.
So I'm using key value coding approach now:
datePicker.setValue(<# your bg color #> , forKey: "backgroundColor")
I had this same problem. I just created a UIView and put it behind the UIDatePicker
datePickerBackground = [[UIView alloc] initWithFrame:myDatePickerView.frame];
datePickerBackground.backgroundColor = [UIColor whiteColor];
[self.view insertSubview:datePickerBackground belowSubview:myDatePickerView];
I declared UIView *datePickerBackground; in my class. I reuse this same ViewController so I set datePickerBackground to nil on unLoad.
Simple follow these steps
First you set the delegate in your .h file like:
UIPickerViewDelegate, UIPickerViewDataSource
Then add that line where you created the datepicker
YourDatePicker = [[UIDatePicker alloc] init];
YourDatePicker.backgroundColor=[UIColor whiteColor];
In your case the color is white but you can change it to as you want.
Normally, I would say that UIDatePicker inherits from UIView and that you could set the background programatically via a line like yourDatePickerRef.backgroundColor = [UIColor whiteColor];, but it turns out that -- according to this related question -- UIDatePicker has a number of subviews inside of it, some of which are the backgrounds views.
It's these subviews that you need to set the background color to white (instead of clear or whatever it's currently set to).
Yes, it's a bit of a pain, but this makes UIDatePicker a potentially powerful object in terms of being able to customize the appearance of.
Why not add a plain UIView behind the picker. Set the view's background color to white. Give the view the same frame as the picker.
Note (based on your comment to Michael's answer):
Digging around the private subviews of a UIDatePicker is risky. It could break at any time. It is almost guaranteed that your solution will break for date pickers used on a device with a locale that doesn't use AM/PM since the picker will only have two components instead of three.

UiBarButtonItem Same Color as "Done" Button

I want to be able to programatically add a UIBarButtonItem to a Navigation Bar and set it's tint color to the exact same blue shade as Apple's "Done" UIBarButtonItem.
I am already doing this for Apple's red shade in this block of code:
UIBarButtonItem *myDeleteButton = [[UIBarButtonItem alloc] initWithTitle:#"Clear" style:UIBarButtonItemStyleBordered target:self action:#selector(myDeleteItemsMethod:)];
myDeleteButton.tintcolor = [[UIColor alloc] initwithRed:1 green:0.0470275 blue:0.0116515 alpha:1];
self.navigationItem.rightBarButtonItem = myDeleteButton;
I guess all I need are the RGB values.
I'm having a hard time trying to "reverse engineer" a UIBarButtonItem's tint that was made in Storyboard (Can't cast UIColor as text).
And I also realize that Xcode's color palette has an area for "developer" color schemes but it does not appear to include the color for the "Done" button.
I spent about 15 mins with my DigitalColor Meter and basically guessed and checked until I finally got it. The problem is that you're adding a "tint" to a black button to make it blue, so it won't be the right blue. Here's the correct measurements:
[buttonName setTintColor:[UIColor colorWithRed:34.0/255.0 green:97.0/255.0 blue:221.0/255.0 alpha:1]];
Hope it helps someone :)
You want UIBarButtonItemStyleDone rather than UIBarButtonItemStyleBordered.
The proposed color of user1641653 is just the bottom color of the real DoneButton taken with the color meter. The problem is that the shadow of a plain/borderer button is different than the one of a SystemButton. The shadow will change the proposed color by -11, -36, -11.
So if you really want it to look like the real DoneButton you have to add those values to the proposed 34/97/221.
This means:
[yourButton setTintColor:[UIColor colorWithRed:45.0/255.0 green:133.0/255.0 blue:232.0/255.0 alpha:1]];

UITextField with black background, clearButton not visible

I try to display a UITextfield with a black background.
But with this black background, the clearButton is not visible.
I can touch it... because I know where is supposed to be, but until
I touch it, nothing is visible.
Here's my code:
textField.background = [UIImage blackColor];
textField.clearButtonMode = UITextFieldViewModeAlways;
How I can make the clearButton to appear ?
Thanks !
You'll need to draw and manage your own clear button, because there's no API for changing the appearance of the built-in button. Read about the rightView and rightViewMode properties of UITextField.
I think you may want to use UIColor to set the background:
textField.background = [UIColor blackColor];
I've created a subclass of UITextField. In this subclass, I used rightView to add and handle a custom delete button. This is the only solution I've found.

How to change divider color in iOS for UISplitView

Is it possible to change the color of the divider? If so, how?
I've researched as much as possible here and on Google, without luck. I'm surprised it isn't more common...
Thanks
On iOS 7, the fix is to set the background color of your UISplitViewController to the same as the deep background color (probably black).
There is a quicker and better way of doing it. Just change spliViewController's view backgroundColor property:
splitViewController.view.backgroundColor = [UIColor greenColor];
In the detailViewController of the SplitViewController, I added the following code to cover up the black line. My custom header is blue and 88px tall.
//blue line that covers the vertical black separator in the header
UIView *blueHeaderSplitViewSeparatorMask = [[UIView alloc] initWithFrame:CGRectMake(320, 0, 2, 88)];
[blueHeaderSplitViewSeparatorMask setBounds:CGRectMake(320, 0, 2, 88)];
[blueHeaderSplitViewSeparatorMask setBackgroundColor:[UIColor colorWithRed:0.0f/255.0f green:96.0f/255.0f blue:182.0f/255.0f alpha:1.0f]];
[self.view.superview addSubview:blueHeaderSplitViewSeparatorMask];
You mean the one-point line between the left and right view controllers? No, UISplitViewController doesn’t expose a way to change that. You might try creating an opaque view with the same size as the split view controller’s view and its backgroundColor set to the color you want, then add it below the other two controllers’ views like this:
splitController.viewControllers = [NSArray arrayWithObjects:leftController, rightController, nil];
[splitController.view insertSubview:theBackgroundView atIndex:0];