I want to begin text entered into UItextview from center both horizontally and vertically, please some one help me.
set Alignment as center.for that select the textfield from .xib class and go to the library and in that set Alognment as center.
Related
everybody some I'm having some trouble vertically centering the or label between the Sign in with apple button and also the login button. Keep in mind that I am creating the SIWA button programmatically and setting the constraints that way also. I have tried getting the origin y coordinate for both buttons, dividing them by 2 and then setting the vertical constraint from the login button to the or label to be (loginButton.frame.origin.y - (divided by 2 value)) but that doesn't seem to work. Thanks for your help.
There's a couple ways to solve this:
Put the 2 buttons and the label in a vertical UIStackview with distribution set to equal spacing. Stackviews are very flexible too, especially in more complex layouts.
Create an empty UIView that sits between the two buttons, then add the label as a subview and center it. Alternatively, you can create 2 spacer views with equal height constraints above and below the label:
V:|[Button][space][Label][spacer2(==spacer1)][Button2]|
Very easy approach: by default, UILabel centers its text vertically in its frame.
So,
constrain the Top of the Label to the Bottom of the top button
constrain the Bottom of the Label to the Top of the bottom button
All done :)
I am using autolayout, I have put constraints on textfield such as same width, same height bottom alignment left and right align to certain controls. My problem is that I am not able to do content vertically alignment center. I tried both from xib and coding but it is not working and comes aligned to top. I am using xcode5. These problem occurs in any ios(I am basically developing from ios6 to ios 7). Please help.
I am having problems figuring out why Xcode is not respecting the constraints on my iphone xib file.
This is how I set a button in the xib file:
and this is how it appears in the simulator:
and this is how it appears in the simulator:
I defined the size of the button:
Any of you know what I'm doing wrong?
I'll really appreciate your help.
If you want the button to stay at the center of the view, you just need two constraints.
vertically center in container
horizontally center in container
Add this two and get rid of the vertical space containers.
Don`t no much about constraint but u can remove it with Doing uncheck in AutoLayout in property editor.
And than palce your button and make it center horizontal and center vertical from property editor of xib.
And make all bounds pack in AutoSizing given in property editor.
I have a label in a UIScrollView that gets its string contents from a website. I was wondering how to make the label display the text so that it is not centered, but is top aligned. The text in the label keeps displaying in the center of the label, which looks awkward in a scroll view. I want the label to display the text starting from the top. Thanks!
Call -sizeToFit on this label after setting it's text. If all you have in this scrollview is a label, you could also adjust it's contentSize after that.
If you use auto layout, you need to adjust your constraint of height to "Less than or equals" and update your constant to the maximum you need.
I want my UITextView to show text but not have the text be as wide as the screen. The problem I face with this, however, is that I want the scrollbar to be in the position it's in now. I'm unsure how to do this. Here's an image of the text i want bringing in, to show you what i mean a bit more clearly:
You can customize the position of the text using the contentInset, contentOffset and contentSize properties of UIScrollView (which is the superclass of UITextView).