I have designed an interface in a NIB which has two UILabels. The labels are in close proximity to highlight one particular word in a different colour.
The issue is that on a non retina display the two labels render as desired. See Image 1:
However on a retina display the label for the white text overlaps some of the blue text. See Image 2:
Note that the frame of the white text label doesn't seem to have moved rather the issue seems to be the word wrap on the blue text label.
Has anyone seen this before and figured out a quick/ painless cure?
Posting as an answer as requested:
This looks like a possible bug or edge case with the larger label's size. If you widen it by a single point, it may wrap correctly on both devices. It may be worth reporting this as a bug, since the objects should behave identically on retina and non-retina devices.
This will be a non-issue for you in iOS 6, anyway :)
Related
So I am quite new to Unity Development, and I have run into a problem. I have two UI's in my game (two buttons), however, when I change the device from an Iphone 12 (landscape) to a Iphone 11 (landscape), the UI's ratio goes all whacky and it changes size. Is there any way I can prevent this? I will link photos below
So this is what it looks like if the camera is in the Iphone 12 landscape 'mode'
and this is what it looks like in Iphone 11 'mode'
The ratio and size of the UI goes all whacky. How do I fix this?
(a picture of my canvas inspector
One thing that comes to mind is to change the Canvas Scalers UI Scale Mode from "Constant Pixel Size" to one of the other options, depending on what works best for you.
Unfortunately, "Constant Pixel Size" is the default value and it usually breaks everything when building a full screen UI.
For canvas settings, use the "scale with screen size" option and play around with the values. If most of the resolutions look fine but there is a spesific one that straight up breaks your UI, you can write a script to check if its that resolution and change the canvas values.
For UI elements you can play around with the setting I circled in red.
Also you might want to check this thread.
I'm a bit confused about when to use autolayout and/or size classes for certain situations. On my initial view I have 2 buttons, one "continue with facebook" and one "register via email", stacked vertically. I initially set these to have around 70 height and 18pt font, and it looks great on the newer phones, but on the smaller ones they look enormous and combined (with spacing) end up taking up almost half the screen.
So my first thought was to make the buttons a percentage height of the main view or a subview, but things just started getting really complicated really fast: do I use percentages for the margins and spacing as well? Where does it end? It's a lot of calculations.
But I also don't see how it would be useful to use size classes here, since my app is only in portrait mode, and I can't really target say iPhone 5 vs iPhone 6 in that way.
So do I have to bite the bullet and use percentages to get nice looking buttons on all screens, or should I just suck it up and have really fat ones with a big font on the now less-used phones? And when it comes to font size, is there a generally accepted standard set of sizes (for headers and body text, for example) that looks good on all phones?
did you try use an aspect ratio constraint? if you use that then keep the distance from the edges fixed and it should squash proportionately for the different screen sizes
I've recently been implementing a new project on Swift, targeting iOS 8+. The UI mixes storyboards and XIBs, using autolayout for everything.
I recently took a look at the application using the "color misaligned images" debug feature in the iOS simulator. All my images are fine but for some reason almost every label and textview I have is showing up as magenta, meaning they are supposedly misaligned. All of these views are aligned using autolayout, which is supposed to be very good at avoiding misalignment. Any thoughts on what is going on here?
EDIT:
Nevermind, turns out it was just another Stupid User Error. I forgot I had a scaling function for forcing downscaling on some fonts based on screensize. This was returning fractions which was causing the misalignment.
maybe this will help?
http://blog.xebia.com/2013/07/19/ios-pixel-misalignment-why-its-bad-how-to-fix-it/
"How To Fix Pixel Misalignment?
Once you have found your culprit. It’s a good idea to start looking through your code to determine how the actual frame of the misaligned screen item is calculated. Some debugging will help you here. I’d look in any layoutSubviews or loadView calls for any divisions being performed on view frames. Also using Font metrics in your calculations is a common cause for misaligned images.
Most likely you will have found your culprit pretty soon. How to fix this? There are two ways to go about this. Either use a floorf or ceilf on the exact value causing the misalignment. Or pass the CGRect for the views frame through a CGRectIntegral call.
When it concerns an image on a retina device, make sure the retina version of that image is actually exactly twice the dimensions of the non retina image. Faulty dimensions on retina image resources is a common cause as well for pixel misalignment. So get check those image resources if they show up magenta."
We use a custom font face and custom font sizes in our application.
When running the application on an iPhone 6 (haven't tried 6+ yet but I assume it's the same) all fonts look blurry. We also have an internal tool that uses the system font and it looks blurry as well.
Why is that and what is the right approach to get them to render as crisp as they do on an iPhone 5?
Perhaps your labels or drawing points aren't on an exact pixel, but instead on a fractional pixel. To prevent such situations use methods like ceilf(), floorf() and CGRectIntegral().
I'm using a full screen UIWebView to house/render an HTML5 application under iOS. Very much like Cordova/phonegap although I'm not using those. I try to make my webview size match the underlying display. Unfortunately, on retina displays, the value returned by self.view.bounds relies on the UIScreen scaling factor. So I get 1024x768 instead of 2048x1536. Not a huge problem except I then instantiate the UIWebView using the smaller bounds (after adjusting for the status bar) and some things get a bit jaggy. In particular, I use canvas at a couple of points and also rounded borders appear thick. To be clear, this isn't a case of scaled raster resources.
I'm not getting the full resolution of the screen using that UIWebView. Ideally, I'd like to set the screen scale to 1.0 but that doesn't appear to be supported. Any suggestions on how best to get full advantage of the screen?
The problem is most noticeable on the iPhone 5 simulator. I don't have that hardware to test on. iPad/new iPad I think has the problem but the jaggies aren't as noticeable.
Update: The more I look at this, the more I think it may be restricted to canvas.
Solution: In case anyone else gets here. Based on the answer below, I created all of my canvas elements with width and height multiplied by window.devicePixelRatio and then set their style attribute to have the original (device independent) size.
See https://stackoverflow.com/a/7736803/341994. Basically you need to detect that you've got double resolution and effectively double the resolution of the canvas.