Is Interface Builder Really Pixel Accurate? - ios

I often find I need to programmatically nudge GUI elements around programmatically after I lay them out in IB. Can someone please give me the low down on the pixel accuracy of IB?
Adobe Illustrator? Pixel accurate. IB? Hmmm ...
Thanks,
Doug

it should be as pixel accurate as laying the objects out in code. If you find yourself needing to nudge the items. It may be because the content placed in them is making them a different size.
In the Size Inspector check out the Auto Sizing options. Perhaps you are expecting them to be center aligned when they are actually left aligned.

Related

Rotate UIView in place when orientation changes

Briefly, I want to properly use autolayout (and maybe size classes) to get a column of UIViews to rotate in place when the orientation changes. I can get the correct before and after looks (see images) using a UIStackView, but the transition is not what I want: each little image-label combination should rotate individually. I have tried embedding the image-label pair in a wrapper view, setting constraints in various plausible and implausible combinations... going crazy. Would prefer to use IB as much as possible, but willing to go to programmatical if necessary.
It's so easy to visualize this that one thinks it should be comparably easy to implement. I know enough linear algebra to do it all by hand, but really can't I stand on some tall shoulders?

Should we use integer strictly when we layout controls in iOS? Why?

I need to draw a line on the screen. The designer tell me to set the height of line to 2.5 pt. I'm wondering if it's acceptable to use decimal here.
I know it will be better if we use integer as the size or position of a UIView. But I can't tell why. I didn't find any convincing document about it.
So could anyone explain it or find something for me?
The only problem I know is UILabel with decimal size will be blurry. Is there any other problem like performance problem would happen?
As per your case it's just about half point which in my opinion should be ok. I often find that in storyboards my frames get moved 0.5 point up or down when I have lot of UI elements and sometimes constraints just get confused.
Additionally: the easiest scenario when your frame could be positioned at "some 0.5 point" is if you use a constraint to centre your view in it's superview. In this case the default x or y frame position could easily end up being "some 0.5 point". So it can happen often times and could be done by Xcode itself, so that's why I think your view will be just fine.
As stated previous in comments those points are CGFloat. What we have now is 1x, 2x and 3x resolutions. So there will always be the need for some calculations for at least one of the devices.
You may also look at this Screen resolutions guide to see all the time when up sampling and downsampling occurs.

Suggestions for drawing a complex hierarchy at multiple sizes

I am trying to think of a way to render a sub-hierarchy that is somewhat complex, and would look good (crisp) when drawn at multiple scales.
I would expect there to be some container view with a size, and this subview could be constrained within it and drawn properly.
If it helps think of a hierarchy like a calculator keypad or computer keyboard even:
You would have a keyContainer view, and a bunch of key views (or layers) of various sizes and positions.
Suppose I wanted this to be drawn in a container that was 320 x 320. I was thinking if I knew the ratio of w:h for each key and I knew the ratio of a key's width to the width of the whole container, then I could work out the sizes and positions for the key. I've found in practice the math seems to introduce a lot of rounding errors and you end up on off-pixel boundaries so the final rendering does not look great.
So how would you tackle a problem like this?
Thanks for any ideas.

PaintCode, How to add a frame around a portion of a vector and have it dynamically resize?

I've imported a vector layer from a psd into paint code v1, I'm trying to create a background image and make it universal.
I can't seem to add a frame around the vector, to complicate matters, I only need a portion, the center, of the layer. (The design is based around a circle, it has lines drawn towards the center of the circle.)
I can’t seem to add a frame to dynamically resize the part I need.
I found this http://www.raywenderlich.com/36341/paintcode-tutorial-dynamic-buttons the part about frame ans groups doesn't help me....
When I add a click frame and drag it around the area I need, it's at the same level as the vector layer. I've also tried adding a group around both, but that doesn't seem to obey the frame size either.
I’ve looked through the tutorials and googled adding a frame, but I can’t seem to achieve what I need.
EDIT
A frame is supposed to be at the same level as the vectors you're working with.
All you do then is set the resize rules of your vectors. There is a little rectangle in the frame's parameters interface with straight arrows and springs that you can modify to fit your wishes.
I think I also remember a checkbox setting to resize only what's inside the frame.
Now I haven't used PaintCode for a while, but if this doesn't help you, there probably is a problem with your vector layer.
I don't know if this information helps.
But if you resizing doesn't work as you expected. Look carefully at the transformation box (the one with the springs attached). When you have put a frame around your object. The middle dot in this box should be blue instead of green. if t's green, you may have a problem with the originating point of your objects and then the resizing may not work as you expected.

"Frame Rectangle" vs. "Layout Rectangle" in Xcode

What's the difference of the two?
I haven't found any difference in my projects when using either one, but it's bothering me that I don't know what either is for.
Please advise!
The layout rectangle is the apparent visual size of the control. It is different from the actual frame, since there might be drop shadows or inset effects that are outside of the visually distinct portion of the control.
What's the difference between frame and layout in Interface builder's size inspector?

Resources