Size classes terminology issue - ios

When I change to wc|hAny from the bottom bar it says Base Values for all compact width layouts. And when I do wC|hR it says Final Values for all iPhones in portrait. I am confused by these Base values and Final values. What is the difference and use of these. I am having a lot of trouble with these.
Thanks in advance.

The answer is on the little green dots!
When you see various green dots lighten up, this is a base value that can be used for ANY size (be it height or width). When you see just one green dot over the shaded area, than it's a final value, as the current size class will only work for this size.
More info here: https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/SelectingASizeClass.html

Size Class provide a way to adapt all kinds of devices with landscape and portrait. I give
you an example : you can design iPhone's portrait view use wC|hA, and switch to landscape use wA | hC , then if you want to adapt iPad , only to choose wA | hC ,and It does not affect the iPhone's composition.

Thanks to mcatach for the reference, first of all, it's good to understand what is 'Any' - it's a mix of Compact and Regular width/height. You can see
when you select the size class Any for either dimension, green dots in tiles indicate areas where your base value design specifications take effect for this size combination. For example, for the Any Width | Any Height combination, green dots in all of the tiles show that the layout constraints and views that you specify on the Interface Builder canvas apply to every device size and orientation.
So you can play with that, you're choosing 'Any' and tiles are highlighting in 'Compact' and 'Regular', because it's combination of them.
And the answer is when you're choosing 'Any' width/height it will be Base value for both or one of them because it fits for 'Compact' and 'Regular'.
"When you select a specific size class for each dimension, a single green dot in a tile and the label Final Values indicate that your layout values apply exclusively to the shaded tiles on the grid. For example, when you select Compact Width | Regular Height, changes to layout constraints and views apply exclusively to iPhone devices in portrait orientation.
So 'Final' means "special for" or "specific" for concrete device/ group of devices and 'Base' fits for 'Any' (Compact or Regular).

Related

Swift / how to change autocontraint value depending on screen size

I am using an extension to identify the device. I have a UIImage that appears too large on an iPhone 5S. I want to scale the constraint depending on the device. I want it to be like that:
if modelName == "Simulator" {
cell.eventsImageViewWidthContraint = Original * 0.8
}
What is the right code to change the constraint size (at the moment 360), to about 0.8 this size.
It looks like you're constraining the width of the ImageView to be a constant at the moment. There are 2 options I'd suggest as an alternative to using a constant. I'll assume you're using Interface Builder.
Constrain the left and right edges to a certain distance from the containing view.
Constrain the width to be a ratio of the width of the containing view. This can be accomplished by ctrl+dragging from the image view to its containing view and choosing "Aspect Ratio." You can fine tune what dimensions you're enforcing a ratio on by clicking the constraint in Interface Builder and adjusting values in the Size Inspector.
You can also try Size Classes to change the dimensions of views based on the general size of the screen.
If you are using code follow the advice above. If you are looking for an easy solution in code get the frame of the size view and calculate using those numbers. For example:
yourView.bounds.width = 0.5 * yourRootView.bounds.width
This code sets the width of a view to half the width of its root view

Setting up variable constrains in xcode

I'm having trouble setting up constraints.
This is the thing I am trying to achieve:
I have 2 objects A and B. I want there there to be a maximum of 100 points between A and B if its a larger screen, or less if its a smaller screen.
Also, I want there to be a minimum of a 20 point margin from the main view controller. So on a smaller screen the minimum spacing will be 20 points, and on a larger screen the margin can be as wide as needs in order to satisfy the space between A and B at 100 points.
To illustrate how I want it to look on various screens:
4 inch screen
I want there to be a 20 point margin on either side and the middle (space between A and B) can be variable, i.e. 100 or less.
5.5 inch screen
The margins can be variable and expand as large as they need to, but the middle section (space between A and B) can be a maximum of 100.
Any help how to achieve this would be greatly appreciated.
This can be achieved with help from three dummy views and two width constrains with different priorities. I set up a test project to test my thought. check it out to see whether it's what you needed
https://github.com/dopcn/testSeg

iOS: Modify a font height, width, and spacing independently when creating PDF

In an iOS app I need to use a specific font but each character needs to be taller, thinner, and the spacing closed up to fit correctly. Is it possible to stretch/squish a font programmatically?
When you're adding text to a PDF file there are multiple ways to influence how the text is going to appear. The most generic way (and the way that might actually be sufficient for you) is to scale the text matrix:
void CGContextSetTextMatrix ( CGContextRef c, CGAffineTransform t );
As mentioned in the comment by #mkl, you can provide a matrix that will scale up in the Y direction while scaling down in the X direction. The effect will be that the letters are stretched out vertically and squished horizontally.
Normally I would expect you don't have to touch the spacing in that case, as spacing will be "squished" together just as the other characters.
Just in case that isn't sufficient, PDF actually does provide a way to change the spacing between characters too:
void CGContextSetCharacterSpacing ( CGContextRef context, CGFloat spacing );
While Apple's description talks about "additional space" to add between characters, the PDF specification and I suspect Apple's implementation as a result allows the spacing value to be both positive and negative. A negative value would have the effect of moving the characters closer together.
Seems like the best option would be to create your own custom font.
You are able to change the kerning of your font (the space between the letters) and the thickness/thinness of the font, however you probably aren't able to edit the height of the font, unless you edit the bounding box the font is inside of to scale the letters differently.
You might also want to consider using a different font...or if you're REALLY hardcore you can edit the font yourself using photoshop/illustrator.

IOS Swift resize label font size when screen size changes

I have multiple labels in the storyboard using the any X any Resolution as follows:
Now I have added constraints to the best of my knowledge to force the labels to reposition when an iphone simulator is used and the following happens.
What I would like to happen is have the labels remain the same distance apart from each other proportionally and just resize their font size. So If we were to divide the Iphone screen into thirds Days would occupy the first 3rd, months the 2nd, and Years the 3rd. I thought maybe using aspect ratio for constraints would work but I got the same effect of the labels bunching on top of each other. It looks like they maintain the constraint of distance from the edges but they wont resize themselves to keep the ratio.
Thanks
If you want to keep same distance between each of them, one way of achieving it is:
Give all of them equal widths constraint. and set leading and trailing constraint to zero. Align all labels to centre horizontally.
This way, you wont need to change the font size..
But, however, if you still want to change font, go to attributed inspector for label and under auto shrink: change fixed font size to minimum font size and set it to appropriate value, say 14.

Spacing In VLayout

I am working inside a Tabpane and I want to have 2 buttons on the bottom-right of the tap-pane, so I thought I just add a LayoutSpacer, but this resulted in
but I wanted it to look like
How can I make my Layoutspacer "bigger"?
In Smart GWT there are different methods to set the size of the component's vertical dimension.
Try with any one
canvas.setHeight100()
canvas.setHeight("100%")
canvas.setHeight("*")
Layouts may specially interpret percentage sizes on their children, and also allow "*" as a size.

Resources