Add text above image in UIButton - ios

So I have UIButton's all over various VC's and Scenes on my game. Some with images others just plain text. So I want to combine both. I know I can do both but the button is then in the background. Is there anyway I can make sure that the text is above said image and the whole thing is clickable?
Everything i'm doing is via the storyboard and not programmatically but i'm fine with doing programmatic. I'm looking at the API as we speak and it seems that I'll have to deal with edges? Never done that before so, just need some guidance :/
The guide I looked at before on stackoverflow was from 5-7 years ago and applies which is fine but setting the edges isn't as self explanatory as it might seem :/
Here's what I have:
dosplayas.titleEdgeInsets = UIEdgeInsetsMake(((dosplayas.frame.size.height)*(-(2))), 0, 0, 0)
I also tried positive two and I tried it as the first of 4 parameters because the first one is the top according to the API

When setting image, just set background image rather than regular image. it'll allow text on top
Then change text to attributed rather than plain
Then..here's a screenshot:
-click the 3 dots
-change the lining to like 7-20 depending on the size of your text

Related

How do i place a button in the background?

I have quite a few labels and buttons on my view controller and I have an image and I have set it to the back in the layers part on the left. How ever when I make it bigger it seems to go to the front and block the images. I have tried multiple codes from other people who have the same problem, but it still doesn't work. I am using Xcode 8, Swift, iOS.
In interface builder you can change the order of what is in front or behind by changing the order of the views as they appear in the Document Outline...
The higher up the list they appear, the further towards the back they are.

iOS Add Image to TextField

I am experimenting a little bit witch apps programming.
How I can add a UIImage to a UITextField"?
Like Whats App or the most other Chat Apps.
I have search some time but doesn't find a solution, also i have tried to search in side of XCode with the auto complete but I have not found a function. So I hope you can help me.
The easiest way to add an image to a text field is to have a UIView that contains both UITextField and a UIImageView as subviews.
Next up, you can have a UIButton with both an image and text, and just set userInteractionEnabled to "NO" and it'll behave like a text view with an image next to it.
Now to get more complicated, if you want a chat-like text field that allows text (that you can type into) and images next to each other, you need to start thinking about custom subclasses. Other people have asked and have gotten answers for this same approach.

How to darken the reorder control in a UITableViewCell?

I have a pale green coloured tableview and when I enter Edit mode the reorder controls on the right edge are almost invisible. Can anyone tell me how to either use my own image for this or darken the system image?
I'm answering my own question because I don't want anyone else wasting time on this. You can't change this... I have resorted to switching my TableView's background colour back to white when I enter editing mode. This is yet one more horrible compromise but c'est la vie! Same with the right chevron in the accessoryView. It would seem obvious that one might be able to set this to the colour of their choice. Not so. The only way I found for doing this, simply darkening the chevron, was to subclass a UIControl and write my own drawRect method. Apple has an awful load of money yet cannot appear to employ enough programmers to keep a handle on this sort of very, very simple UI stuff. It appears that the bigger the libraries get the less we are able to actually do with them.

Is it possible to 'hyperlink' text within a UILabel/TextView but activate a segue on tap of this 'hyperlink'?

I say 'hyperlink' because I don't know what else to call it, and that is how i'd like it to appear.
Obviously this is possible using a combination of labels and buttons, but my labels and buttons are programmatically generated and I imagine i'd have to also programmatically arrange them, which would likely be tedious and inflexible in terms of changing font sizes etc.
Any ideas/approaches would be much appreciated!
As an example, look at Instagram's following and news feed:
You should set userInteractionEnabled and then add a UITapGestureRecognizer to the label.
Have a look at Nimbus Attributed Label it can provide the functionality you are looking for.

Designing a circular "selector" control

I'm developing an app that calculates poker odds, and now I'm facing some problems with the card selector.
This is a mockup of what I want.
I've found two ways to accomplish this. The first one is to use an entire UIImageView and detect touches, calculate where the touch has been generated, and set the corresponding value.
The second one is to use a lot of UIButtons, but in this case I get problems with the shape of the buttons.
Of course I can use a regular UIPickerView and so on but I think that the one I've designed is better.
if you have a UIButton with a background image that is shaped irregular. then that is the only point that the button can be pressed.
Change the type to custom and put your slices into buttons.
This has been my experience anyhow.
My buttons have to have a .01 alpha background to increase their pad size and people can push the button.
Hope that helps :)
After googled a little i've found https://github.com/ole/OBShapedButton .
it does anything what i need

Resources