I want to change background colors of UIActionSheet buttons.How can I do that ?
There is no way to change UIActionSheet button colors, apart from adding a destructive button that creates a red option. If you really want custom button colors, try making a custom UIActionSheet like so: custom-uiactionsheet-using-core-animation
I had the same issue and only clicked together a basic solution.
The core animation approach is superior but that may be simpler
https://github.com/Daij-Djan/DDUtils/tree/master/ui/M42ActionSheet%20%5Bios%5D
Disclaimer: mine ;) and also not the coolest code since its from 2010 but it should work fine
Related
I am trying to change all my UIAlertController's tintColor to a custom color because there are lots of these in my app and I want to go shortcut. After a little research on the internet I found this snippet and it seemed working at first.
UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = UIColor.red
Later, I realized a bug -or anything else, I don't know yet- that this snippet has effect on UIToolbarButton's tintColor. It has been set to a custom color on the storyboard and I tried to set programmatically in related viewDidLoad but it does not work. The color of the text is default blue. Moreover, I also tried to set UIView.apperance.tintColor directly it worked on that button but, for that situtation the items that should have meant to be white turned to that custom color. As you can understand I don't want that.
If someone helps, i will be appreciated because he will save me from all crtl+c and ctrl+v process:) Have a good day!
Good morning, good evening !
I feel like my question is a dumb easy to solve question, but it looks like Google can't help me.
I want to add on my UINavigationBar a search button, but I want it borderless !
When I set it through Xcode I have this awful kind of button :
And I want this kind of button (from the Dropbox app) :
That would be nice if someone is able to explain me the trick to achieve this !
Thank you.
I think you have a bar button item. I have played around with it. And the Bar Buttom Item has to have a Tint of Clear Color. The actual Button a Type of Custom. Then it comes out more the way you want it (I think).
In my IB it looks like this:
It is the following
With properties like this:
And like this:
Hope it helps.
If you use Interface Builder set the button type to custom and use your image as background for the button.
I can select multiple font styles in Apple Pages app, orange colored box on the screen.
How to make it?
I can't find any ui component in the iOS SDK like this, multiple select. UISegmentControl is only for one select like radio button.
use a UISegmentControl in momentary mode to have the bar :)
set custom background images for the cells
there is no stock control but this is quite basic using this approach
No default thing is available you have to do it by yourself. You set tags for each button and only one selector. By checking the selected button tags execute you specific code.
For that, yon need to take UISegment Control and make it's background images custom. Also you can set the width of the each segment.
Then you will achieve your goal.
Cheers!
I have a problem with the text shadow of the UIActionSheet buttons. At iOS 4.0.2 long string were truncated automatically. No at iOS 4.2 these texts are presented with a smaller font. But now the offset of the shadow is corrupted and to big.
Is there a possibility to change/remove the text shadow of the UIActionSheet.
EDIT: I'm building the UIActionSheet not with initWithTitle:, but with the normal init and sets all needed properties afterwards because the number of possible buttons is dynamic and the texts cannot be change. I've tested it with initWithTitle: and got the same results.
You can refer this to truncate your string before displaying it in a UIActionSheet.
I can think there are two workarounds for this (although I would not them myself in my application, reason listed below the workarounds):
In the first case you access the sublayers of UIActionSheet, get the labels, change the shadowOffset and shadowColor before presenting the actionsheet.
Secondly you can initialize the actionsheet with blank titles and add your own labels as subviews on the actionsheet at right places. (More tricky then the first approach).
Now the first approach is very risky as the layer structure of UIActionSheet can be changed by apple in future updates, hence your application may break and would not give good results.
Continuing with second approach is good only when you can calculate the exact frames where you should put your lebels so that they look good. But in your case the number of buttons would also vary, so this approach will take a lot of time initially to get the things working.
Hence, I would go for truncating the strings before I set them as the title of buttons.
Not sure how much would this help. But I am sure that truncating strings before setting them as titles is the best option.
are you doing anything non default for displaying the text?
If you only use UIActionSheet-initWithTitle:… you should write a bug report to Apple.
OR shorten the text to "Frankfurt International (FRA), DE" ;)
This appears to be fixed in 4.30. I found no way of fixing it in 4.2x.
What I'm trying to do is replicate the NSTokenField like UITextField seen in the Mail app and Messages app (type a contact and it comes up with suggestions).
I've got the autocompleting working perfectly, when you type in a UITextField, a UITableView pops up showing any matches that it can find in an array, when you click one it adds it to the UITextField. I'm really happy with this so far.
The problem I've run into now is making the controls look like those in the native apps. Afterall, design is everything!
My first question is how can I add that shadow look to the UITableView? Looks like it's sunk down behind the UITextField.
Secondly, I know I'm going to have to subclass the UITextField to make it look the way I'd like it to, but I've got no idea where to start with that. Some pointers or a sample would be great!
Lastly, I think I need to create a custom UIButton with space for text and the blue gradient then add it to the UITextField. Same problem as with the UITextField, not really sure how to subclass the UIButton (what methods it needs to draw and stuff) or how to add it to the UITextField in such a way that when you click backspace on in the UITextField, the button will be highlighted, then deleted if backspace is clicked again (exactly how the NSTokenField works).
I've included an image just so you can see what I'm talking about:
http://www.thermoglobalnuclearwar.com/stuff/mail.jpg
I have taken a look at Joe Hewitts Three20 project but I couldn't make heads or tails of it.
I'd like to start very simply and understand everything that's going on rather than just dragging his code into mine and not having any idea what's going on!
Any help is greatly appreciated!
Thanks,
Tom.
Have you considered using the Three20 library? It contains a control which I think does what you want (TTPickerTextView).
As the website description states
TTPickerTextField is a type-ahead UITextField. As you type it searches a data source, and it
adds bubbles into the flow of text when you choose a type-ahead option. I use this in
TTMessageController for selecting the names of message recipients.
At a minimum the source code might give you some pointers on how to achieve the various visual effects.
Okay, I've got the shadow working underneath the UITextField, and I've added the "To:" label to it. It looks great!
So the final thing is the blue NSToken like control. I've started to think the easiest thing is just to subclass a UIView and draw the blue gradient and label inside it. Which brings me to some more questions:
I found this: http://github.com/leonho/iphone-libs/tree/master which draws a nice rounded view and I've adapted it to add some text to it rather than a number, what I don't know how to do is draw a gradient instead of a solid block of colour.
After that there's just the matter of adding the rounded views to the UITextField, moving the cursor and working out how to delete the views when the cursor reaches them, but I'll tackle that when I need to.