How do you create resizeable header images for iOS in Photoshop? - iphone

I'm trying to create assets for a native iOS app. I know that I need to make my header images and buttons resizeable, so I'll need to create slices of the capped ends and a middle slice that stretches to full size.
My question is: how do I do this in Photoshop? Should I use the slice tool to make three separate slices and then export them as three .pngs? Or should I slice the ends and the middle, put it all together and export it as a single .png?
What is the best way to do this?
Thanks!

Native iOS apps have an image API that supports resizing single images based on insets and a tiled inner area. See the documentation, specifically -resizableImageWithCapInsets:. With that method, areas around the edges defined by the insets are not altered, while the remaining center region is tiled to fill any size.
You should aim to produce single images that can be used with that API in mind, while keeping tiled inner region as small as possible

Related

Compensate resolution change with size of features in MapBox static API

I'm using MapBox's static API in a project. I have managed to load maps with the same width and height in terms of latitude and longitude regardless of the resolution. This is so that users see the same area regardless of their screen resolution, for example. The problem is that on larger resolutions features and —especially, text appear much smaller, relatively. For example, these two maps look very similar, except for the size of text (and some other details, like the thickness of lines):
https://api.mapbox.com/styles/v1/mapbox/outdoors-v11/static/0.63189425,46.195750258333334,14.3/540x285#2x?access_token=ACCESS_TOKEN
https://api.mapbox.com/styles/v1/mapbox/outdoors-v11/static/0.63189425,46.195750258333334,13.15/240x126#2x?access_token=ACCESS_TOKEN
Is there a way to compensate for this and have the text on the larger image print larger, and have thicker lines? (in pixel terms). The result being that, say, two 6 inch screens print text in the same real-world size (centimeters) regardless of their pixel count.
I have looked into layers and filters, but it does not seem like there is a straightforward way of achieving this. It looks like maybe designing new maps would be the way to go, but I'm using the default ones and I would not know where to start.
THank you
I'm a bit confused by the premise of your question here. The API's #2x parameter is meant to toggle resolution and should serve exactly the purpose you describe. The reason for different amounts of label information being included in the images you've shared is because you've used different zoom values (13.15 vs. 14.3) and the labels in Mapbox core styles are zoom-dependent, meaning they change based on the zoom value used to generate the map.
With a fixed image width, and no #2x parameter:
/styles/v1/mapbox/outdoors-v11/static/0.63189425,46.195750258333334,14.3/540x285?access_token=ACCESS_TOKEN
yields
With a fixed image width, and a #2x parameter:
yields
/styles/v1/mapbox/outdoors-v11/static/0.63189425,46.195750258333334,14.3/540x285#2x?access_token=ACCESS_TOKEN
⚠️ Disclaimer: I currently work for Mapbox ⚠️

dealing with different screensizes when using tiled map files (tmx)

I'm trying to learn spritekit and I'm a little confused by something. I know that I need to have #2 image files which need to be double the size of the standard ones and that once I name them properly xcode will deal with the rest. But, when dealing with tiled, do I need tiled files that are level1.tmx and level1#2.tmx
So here is what I did as a test today:
created two tilesheets, one was 32x32 and the other is 64x64 (the 2x).
create two levels in tiled, one was 64x64 tile sizes and the level size was 2048x1536 (the 2x one). I used the 64x64 tiles on that one. The other level I created was the exact same, but I created it with 32x32 tile size, which made the level size 1024x768 and I used the tilesheet that was 32x32 on it.
So now I have two tmx files and two spritesheets, for one level, on the ipad.
Am I doing this correctly? Once I start doing the iphone I will have 4 or maybe 6 sets for each level?
I assume xcode won't work the same way with tmx files if I name them level1#2x.tmx, right? If not and assuming everything I'm doing above is correct, how to do load the correct tmx file? Do I need to check for device type, then resolution and load my map file based on that for each level?
I think maybe I'm not doing this right so I wanted to stop here and ask before I get any further.
TMX files are not loaded automatically in iOS so I am guessing you are either using the SKAToolKit or the JSTileMap one of the two most popular to my knowledge. Myself and other Sprite Kit Alliance members put together the SKAToolKit so I think I can answer your questions from that point of view because it should be similar for JSTileMap too.
The short answer is build your map using 1x assets, but provide images for standard and retina in Xcode.
First you create your map using 1x assets. When the map is loaded it uses points not pixels. So for example if you make a 32x32 pixel tile map it will be treated as a 32x32 point map. When the sprites are created it pulls in the correct image based on device. If an image is named tree.png and is 32x32 it will take up the space of a 32x32(point) tile. If you have an image called tree#2x.png 64x64 iOS will use that for retina devices. Because it is an #2x image it will take up 32x32(points) but will be 64x64 pixels.
Hopefully that makes some sense. If not let me know.

Drawing route/lines on a custom map image (iphone)

I have a custom map image of an area.. There are about 9 regions and the number of distinct lines needed is only 11 (based on all possible routes).
What is the best way to draw a route on the map?
The brute force/hacky way is to create static images of every route possible- insane as it amounts to over a million images. Another way is to have layered images with the lines as images on top of the map (is this possible? Would zooming mess it up?)... Any other suggestions to tackle this? I could programmatically draw lines on top of the map but would it be responsive to zooming and such?
Note: The map image is a vectored image (svg) and does not contain GPS coordinates
Thank you!
You'll probably want to check out coreGraphics, it's perfectly suited for this task. Zooming and all.

Dragging images from a scrollable region in Raphael?

I'm investigating the feasibility of using Raphael for a user-research project. One of the features allows for users to drag images onto a canvas and we record where they placed it. The pool of images is potentially quite large and we'll have them in a scrollable box in the tool.
I put together a quick wireframe of the issue I'm looking into since it'll probably be clearer than my explanation.
Please see the wireframe:
I'd stick with straight HTML/CSS and use jQueryUI draggables, as you mention in your comment.
You don't appear to need any of the drawing/display features SVG offers, yet if you went that route, you'd have to build your own custom scrolling behavior (instead of setting a CSS overflow-y rule) and picture layout algorithms (again instead of using CSS floats or something).
You can create a scrollable region using Raphael.
Create the viewport with fixed
dimensions (say 800x600)
Draw the images with increasing y value. After few images, the y value will go beyond 600. It will be drawn but will not be visible in the viewport.
Create a scrollbar using raphael rects. Attach drag events to the scrollbar handle rect.
When the handle is moved, translate all the images accordingly.
For e.g. lets assume in step 2, you had drawn all the images and the bottom most point of the end image is having y value 2000. Assuming the scrollbar has length 500, each dx movement of the handle will have to translate 2000/500 = 4dx. You can calculate the handle length similarly using ratios.
Since everything inside a single Raphael paper the dragging of images will work seamlessly. You will have to maintain the positions of each images.
You might find this demo similar
Remember you can always use getBBox when you drop. In this case it's rects but images would be the same..
http://irunmywebsite.com/raphael/additionalhelp.php?q=bearbones

Multi changeable areas of a image on a iPhone

I have an image with picture of a person and I want to let the user to pick some area of the person and change the color. But how can I best create a multi-mask image?
E.g. should the user be able the change the color for a leg or a hand.
I am using Titanium Appcelerator, and right now I had a solution with buttons placed over the image, which is not a pretty and accepted solution.
The Kitchensink example, has only one area which can be changed.
The only solution I found for working with sections of an image is to divide the image into different views then use a vertical or horizontal view to glue them together. Sounds like you took a similar approach using buttons.
Another option might be to use one of the jQuery image libraries within the webview. This most likely will have a performance penalty though.