iPad running iPhone apps and font scaling - iphone

I'm testing one of my iPhone apps on my iPad in "2x" mode, so it stretches everything to double-size. I've noticed that some text appears to be smoother than others. From my (limited) testing, text in a UITextView or UITextField that is being edited (has keyboard focus) is smoother than a plain UILabel hanging out in a view. I'm not sure if it's anti-aliasing in 2x2 pixel blocks still, or just that it uses all the pixels to draw the letters rather than treating them as 2x2 pixel blocks, or something else entirely. From my testing, this appears to be true regardless of font size.
Does anyone know what is going on here?
And, more importantly, is there a way to control this? It looks much better and I'd like to have my plain UILabels drawn this way too! I'm hoping that a future iOS update will allow the iPad to use iPhone 4 "#2x" resources and font drawing when running an iPhone app in 2x mode, that would make them look much better!
Thanks!

iPad's legacy scaling mode obeys CALayer's magnificationFilter property. Use kCAFilterLinear for smoothed/blurry upscaling, and kCAFilterNearest for blocky/crisp upscaling.
Also, if you set the contents property to be a CGImage that is double-sized, QuartzCore will gladly take advantage of the extra resolution.

Related

background images are grainy and slow with iOS 8, iphone 5s

My client asked me to put a bunch of random background images on his iPhone app. So it's set up by putting a UIImageView on top of self.view, adding an FXBlurView on top of that (for blurring purposes, obviously), then putting a UIScrollView on top of THAT, and laying translucent UIViews containing control objects on top of all of it. it looks something like the yahoo weather app when all is said and done. my question is twofold. now that i've explained the situation, here are my two questions:
Question 1
the background images are very grainy. what size should they be for an iphone 5? and what size for an iPhone 6? i thought retina was 640x1136, which should be the minimum size right? why is it only showing the entire image for 320x568? from what i've read, they should be the following for a 5s:
320 x 568
640 x 1136
960 x 1704
when i do that, they appear very grainy. if i do any larger than that then the pictures are cut off. the whole picture isn't being shown.
Question 2
In iOS 7, the app ran fantastically. now that iOS 8 is out, the scrolling graphics are slow and choppy. I took the background image out completely and it sped right back up. I'm wondering what i can do to speed the scrolling up again with a background image staying stationery while the control objects scroll.
any ideas for me?
Answer to the first question
apple has you design your apps at 320x568. The extra pixels are used to make the text and images look sharper. Otherwise, everything would be smaller on a retina display and not sharper.
So you don't have direct control over that extra retina space. The iPhone uses it to digitally make the images sharper and clearer.
I'd still like to know why its choppy and the graphics are poor while scrolling
I use FXBlurView as well, and found that turning the dynamic option of the blur view to OFF fixes the issue. For some reason on iOS 8 FXBlurView uses 100% CPU when dynamic is ON.

Converting an iPhone app to universal; bounds vs frames

I'm trying to convert an iPhone application to work universally (on both iPhones and iPads). I've managed to get the frame to re-size correctly, but it seems like the bounds (the part the user can actually interact with) isn't re-sizing appropriately with it. So, for instance, a UIWebView will be drawn in the correct dimensions, but I can only interact with it within a smaller confine the size of an iPhone screen.
Any thoughts what's going on?
How are you re-sizing this view? Is it in an xib with autoresizing mask set to properly expand? If so something else is going wrong. I just tried making a sample project with a webview, where the xib is sized for iPhone. I then marked the application as universal, and it runs just fine in the iPad simulator with all areas touchable.

UIImageView PNG pixelation on iOS simulator and on device

This may be a very simple issue, but I've been stuck with this for a week. I'm using an UIImageView to display a Dropbox branding PNG image. I see it alright in Interface Builder, but it's easy to notice a strong pixelation in the iOS Simulator and in the actual device (an iPad). Here I attach a screen capture of the IB together with the simulator:
I would really appreciate any hint.
Thanks in advance!
InterfaceBuilder is a completely different environment than iOS or even the simulator. Layout and such should translate, but the way everything looks should always be judged (and therefore designed for) the end product.
It looks like your image is being stretched slightly. There are any number of reasons for this. The first thing to check is the resizing mask on your UIImageView. It's generally bad for UIImageViews to autoresize - for this very reason.
By the way, autoresizing is UIKit's way of making sure that subviews still fit/look good when their parent view changes size. You can specify how much you want a subview to move around, also how much you want it to stretch. Read about it here.
What you will want to do is design your view -- answer the question: how big do I want this image to be in the final product? -- and then make the actual png that size (also produce an #2x variant that is double the size for retina displays). Then, when you design in IB, make your UIImageView that size as well, and make sure that the autoresizing settings are set to prohibit stretching.
This ought to fix your problem.
Check to make sure the size of the image matches the size of your UIImageView. If the image happens to be smaller than the target image view, it will stretch to fill it which could cause pixelation. Also, if you are running the new 5.1 Simulator for iPad, it will default to the new retina screen, which means you will need the #2x sized images to prevent pixelation there.

converting iPad app to iPhone app

I'm currently working on an iPad-specific application.
Since I don't use interface builder, every view element is using CGRectMake with specific numbers for its position and size.
so I was wondering,
if I use the same exact code on iPhone, do these numbers scale accordingly?
or should I re-insert the numbers for all the view elements?
If the latter case, is there any easy way to change it all?
CGRect coordinates are absolute, so your subviews will not automatically scale down to the iPhone. If you run your code on an iPhone, you will see only the upper-left corner of your iPad layout.
You can pretty easily write a helper method to take the original CGRect values and scale them down for the iPhone layout. However, if you're also drawing text you'll need to scale down the font sizes as well (which probably won't work, so you'll still need to deal with the text in a possible not-automated way).
I'm doing essentially the same thing right now, writing a single app that runs on both iPad and iPhone and scales itself in code to the available dimensions. I'm generally setting up the view layouts as a float proportion of the available screen size, and then converting those proportions to CGRect before rendering.
Kudos on not using Interface Builder by the way - IB may be the most ridiculous atrocity I've ever seen in the programming world (even worse than classic ASP, which is saying something).
You'll have to change your numbers for your iPhone app. The points that CGRectMake uses are pixels and don't scale, with the exception of HD devices like the iPhone 4.
Honestly, the iPad is such a different device that your UI probably needs to be heavily modified to take advantage of the extra screen space.

Interface Builder can't display 160dpi images correctly?

I'm developing an iPhone app. A simple image is the background of the main view.
I've set an UIImageView in the background and set an image in, using IB.
the image is a 160dpi PNG image. It appears like CRAP in IB. When running in the simulator it is ok, crisp.
How am I supposed to work and place my controls precisely on a such poor resolution image ?
Is this a bug ?
Thanks for you help!
IB is not a tool for designing a UI, it is a tool for implementing one. It is designed to perform well rather than display well (this is more important in complex desktop UI design than mobile but the tool is the same for both). The best advice is perhaps to take a cue from the publishing world (where this is a common practice for applications that display large amounts of high resolution graphics such as Adobe InDesign) and keep track of exact measurements for controls - the x,y coordinate positions and height/width. Then you can use the inspector to precisely position controls.
Actually, the DPI is not irrelevant at all.
Change the DPI to 72 and the image will display in IB/Xcode fine.
I don't see anything like this when I work with images in IB. Maybe there's something special about your PNG file? You say that it's 160 dpi, which is fairly irrelevant. More important are what its pixel diomensions are, and how they compare to the screen size.
Maybe the UIImageView is having trouble rendering your PNG, and is for some reason using the preview icon instead? Try a different image, or try resizing your image to 480x320, with 32-bit color.
I am wondering about this as well. I don't think the DPI of the image is what is doing this, because I have a project where everything looks fine in IB on one machine, then on my laptop, it displays the way the OP is describing.
The image dimensions are the same as the iPhone screen and the view dimensions (320x480), but the image displays all tiny instead of filling up the whole dimeal nsions of the UIImageView. If I scale to fill, then the image gets all blurry, at 320x480, even though I can confirm that those are the actual dimensions of the image... It's acting as if the image itself is 320x480 of empty space with a small version of my image centered inside it... this is very strange. As I said- this is the same project that looks completely fine in IB on another machine (and when they build, they both look normal in the simulator). This also happens on my friends's macbook.
Is there some setting in IB that might be the difference?
EDIT:
Guess I spoke too soon- I went back to my other machine and noticed the same problem this time, and it indeed was the dpi. This must have been a change in one of the recent updates to xcode/IB, because I originally never saw this issue, and the image files are exactly the same... strange.