I wrote simple iOS app which countdown the time til midnight. I have single text label which is used to display current time. I use NStimer to change the content of that label. The problem is that when the content of the label is changed (in every second)the content moves left and right for about 1px. Is it possible the position of label content to be fixed ?
The position of a label is fixed, make sure the text alignment isn't on center.
Why not make sure this never happens by always showing the time in HH:MM:SS format. Something like 01:11:05 etc. Make sure you override the text alignment and the minimumfontsize function to match the current font size
Related
This question already has an answer here:
Changing text in a UILabel is causing all my imageViews and buttons to go back to their original locations
(1 answer)
Closed 7 years ago.
I'm trying to move an image across the screen and then interacting with a text field. I programmed a buttton that defines what the position of the image is, randomly. Now, if I try to change the text in the text field, the image automatically moves back to its predetermined place. I want to know why this is happening and how can I fix it.
Now, if I try to change the text in the text field, the image automatically moves back to its predetermined place. I want to know why this is happening and how can I fix it.
It's because when you change the text, layout is performed, and so everything is positioned according to the auto layout constraints you have applied to it. You never changed the image view's constraints, so it goes back to where you left those constraints.
I want to fit the Image + Label into Scrollable View.
It looks like so My setup
So trouble here is that width of the picture and the label did not match the screen width.
I tried to change the UIImageView width from 400 to 300 or so, BUT those changes either wont take the effect(if above 300), OR those changes make label disappear (with width setted up on 300 or below). Observe.
Funny thing is - label actually appears when you see view hierarchy, even though it looks kinda distorted. But no label on the iOS screen for you, sir.
I also tried to set equal width and height from the superview, but this option just disabling scroll, making view strictly fit the screen (label appears to be cropped)
I want the label to be nice and scrollable, but I also want to see it on the screen. Too much to ask?
EDIT: I just tried removing Auto-layout and got the same as with auto-layout. (click "Observe" link to take a look again, exact same situation) Could somebody explain why?
This is quite a simple fix. For the image, you should use equal width & center horizontally; however, make sure you use a fixed width. For the image to look nice, play with the scale modes - I find Aspect Fit/Fill work best.
The label should also be equal width & centered horizontally. You may need to calculate the height of the label programmatically if the text isn't always going to be the same size.
So the answer to my particular question was - shortening the actual text that is passed to the label.
Apparently UIScrollView can't handle stuff with crazy abnormal heights (I was passing a huuuge text to it) So in my particular situation solution was - shorten the text. Now it works like a charm (even though I still need to play a little with constraints to get rid of the warnings and stuff)
I am trying to put a background image into a text-field (it's just a search icon). And it is tiling the image in the text field. Is it possible to turn off the repeating of the image? i don't see anything like that, i'm seeing padding and position for background images but nothing to turn off the tiling of the image. is this not possible in pixate yet?
thanks!
You should be able to set background-size to the size of your text-field so it won't have anything to repeat.
I battled this same problem, and in the end, I found I got what I wanted by using multiple objects. Even if you get the search icon to work right, you're probably going to notice the UITextField doesn't pad the text away from the icon.
Anyway, here's how I ended up doing it so that I had full control over the style.
So you can put your search icon in the UIImageView and then define your text field's style (border, background color, etc.) with the UIView. The UITextField ends up being plain white/transparent, and positioned so that its text doesn't overrun the search icon.
I hope that helps.
I'm using vb.net to make a screen saver.
I want my label where the text shows to always be centered no matter what screen size it is.
is there a way to get the screen resolution of the current monitor?
if i can get that then i can calculate the middle and set my label there.
Stretch the label to the whole width of the form and dock/anchor to left and right side within the label parameters. This will center your label whatever the size of the form.
i am showing digits on uilabel and using timer to update text something like counting down..
i am using this font to show time like lcd clock
[CountdownLabel setFont:[UIFont fontWithName:#"DBLCDTempBlack" size:48.0]];
i am facing two problems in this.
using this font the dots(:) between the digits is smaller than the digits.
the digits shrinks while counting down suppose if there is 1 and after it comes 0 then digit become large.and label acts like it increasing the font of that specific digit.
i want following things on uilabel.
a glow effect around the digits.
prevent shrinking(note-i have disabled the Adjust To Fit property of label)
also i want to know if there is any other font available than this to show text like
digital clock.
and finally a request from all of you.
is there a way to run countdown timer using images of digits.
here is an image what i want