can I create a button with text and image together in Storyboard? - ios

I put a UIButton in my storyboard. It looks simple:
its properties are also simple:
I wanted to include an image in this button, so that it looks as follows:
[image]text
but when I put the image name in storyboard:
the text disappears and all I see is:
how can I show both things together next to each other?

It's just a white title on white background.
You should see the title if you set Text Color back to blue or whatever you wish. For some reason it is different on the screenshots you provided.

Related

How to change background color of a UIImagePickerController's Table View?

Using the UIImagePickerController to bring up the following window.
Am able to change the navigation bar color and their text attributes no problem.
How to change the background of this table view's cells AND the background color of this tableView?
Basically all the area that has been painted red is the area I'm trying to change the color of. Please help. Thank you.
UIImagePickerController is not intended to be modified. It should have the system default style and if you modified that, your app will get rejected.
If you want to customize it, you need to look at some custom image picker, not the one that is provided to you by default.

Label over a button

I'm trying to put a label over a button, but I'm not succeeding...
Here's what I have. I'd like the text "tap to dial" to actually be over the dark grey area, not below it. How do I do that?
On the left side of the image is the view hierarchy, the red things left and right are the button add and button remove, so you get the whole picture.
EDIT: Explanation - The label I'm trying to place over the button is the hint what the button does. The button itself will hold different text contents, thus I need an additional label.
EDIT 2: I don't know why is this question marked with negative votes, why don't people explain that in the comments? Let's pose the question differently: if one wanted to put a label over an image, how would that be done?
Select both objects in IB (Interface Builder) and then create constraints so they have both have the same vertical and horizontal center. If the text is under the button then select the text view and choose "move to front" from the editor menu.
All that being said, why don't you use a titled button with a gray background rather than trying to put a label on top of your button?
A button is a label (that is, its title is). So you don't need a button and a label; just configure the label of the button. The label is the button's titleLabel and you can make it do anything a label can do — including consisting of multiple lines, one of which is smaller than the other, as shown here:
The solution I was looking for was to embed the button and the label in a view. Inside the view they can be positioned to overlap each other, while the view itself can be constrained by auto-layout.

Center UIButton with image next to it

I'm trying to create a UIButton where the facebook icon is a part of the centering, however i can't seem to figure out how to make it part of the centering process. So far i've just created a UIButton with the text. I could just create a image next to it, however then it will not be part of the centering.
You can easily set image and title both for your button for different control state like normal,selected or highlighted etc.
So, set your image and title to your button from storyboard or programmatically there is no need to take separate imageview for image.
You can set edge insets for title and image both from interface builder or programmatically. you can manage top or bottom edge insets for title and image of button to manage it's vertical appearance!
check screen shot below,
Update : (as asked in comment)
For example,
this is the setup for my back button with image!
Provide button title and image for normal state. Then just change the left inset for image as per image

Custom the backgroud of a UIButton or UIBarButtonItem on segControl & bars

I'm trying to change the appearance of my UIButtons int the view as well as UIBarButtonItems in the NaviBar or toolBar or SegControl.
And here are 2 questions.
NO.1. How can I set customed background pictures to the buttons I mentioned while I can change their titles programmaticly? I mean I found that if I set the background of a button, the title seems to be concealed by the background image?
NO.2. I tried to add the text of the title directly on the png, ( which is actually a imperfect way since I need to change the title during the runtime). Anyway it works out both the image and the text, but the resolution seems to be reduced because the text became sort of blurred.
Can anyone give me some advices how to achieve it? Thanks a lot!
NO.1 The button title should not be obscured by the background image. Are you setting the button's image in code like this:
[btn setBackgroundImage:image forState:UIControlStateNormal];
? You may be instead setting the button's image property (which is different from its background image).
NO.2 You really don't want to be adding text to the button PNG, for the exact reason you mention. Buttons in iOS are designed to display images and text the way you want - put your energy into getting the built-in buttons working the way they should. There are umpteen billion tutorials out there about how to do this.

How to add a grey description bar under UINavigationBar?

Like this one
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284862083&mt=8&ign-mpt=uo%3D4
The grey bar with text "Most E-Mailed..." will always stay on top when the user scroll the content.
Can anyone give me an idea how to make this?
You can simply add an imageview with this image and set a label on it with what text you wanna display. I think this is what you want.
Here's a blog entry by someone who dissects how the NYTimes app was made: http://www.cocoanetics.com/2010/12/bars-like-the-new-york-times-app/

Resources