I have a myriad of UIImageViews that act as 'tiles' on a map. They align up next to one another to form a grid of images. The layer of each UIImageView is added as a sublayer of a UIView.
Ordinarily, the grid images are flush against each other, but whenever the UIScrollView that contains the UIView is zoomed in or out, the spaces between the tile images become visible, showing off the grid pattern that I'd like to be invisible.
Any ideas what might be causing this?
Sounds like you're trying to create a CATiledLayer from scratch...?
Why not just use CATiledLayer?
Related
I have a UIImageView set on top of a scrollView. The image is a map, and I need to annotate buttons across the map to corresponding locations (very specific to the region). The buttons are visible, and they pan and scale accordingly when scrolled/zoomed, this works great. The issue is when the buttons are rendered on different screen sizes, the buttons are placed in different spots since auto-layout puts them the same distance from the edge of the screen, but the image has a different bounds property and is bigger/smaller depending on the device.
I've considered creating an MKMapView with a custom overlay of this image, but I was hoping to keep it super light-weight and avoid MapKit all together.
Any suggestions? Clarifications are fully encouraged :)
You should add buttons as subviews on imageview so that buttons transform in the same way as imageview does.
Right now I have a UIScrollView and a semi-transparent top and bottom bar which go over it. The UIScrollView contains a large UIImageView that is pannable and zoomable.
I want to be able to toggle the image and darken everything around a certain part of the image, but have the transparency mesh perfectly with the top/bottom bars which are semi-transparent. Since the content is scrollable/zoomable, if I darken the image itself, anytime that part goes under the top/bottom bars it will double darken.
I tried to solve this dilemma by creating a smaller UIScrollView that sits nested between the top and bottom bars, and sending zoom/pan commands to it in an attempt to mirror the UIScrollView below it, but that didn't work too nicely. It was a nightmare trying to sync the animations (I tried copying over the zoomScale/contentOffset in zoomDidScroll, sending the zoom/pan animation to each UIScrollView individually, using KVO, etc).
Is there any way I can set different frame sizes/cut-off points for each individual layer? Or perhaps each UIImageView subview? I'm open to any other proposed solutions as well, this has really been driving me up the wall. I appreciate the help.
What it's like before toggle:
What I want after toggle:
Why not cover the "center" part with another semi-transparent view to match the tool bars, then use a mask on the layer to make the part of it you wish fully transparent?
I have a myriad of UIImageViews that act as 'tiles' on a map. They align up next to one another to form a grid of images.
Ordinarily, the grid images are flush against each other, but whenever the iPhone or iPad device is rotated, or if a UIView is applied to the view that contains these tiles, the spaces between the UIImageViews become momentarily visible, showing off the grid pattern that I'd like to be invisible.
Any ideas what might be causing this?
Thanks
Consider using CATiledLayer to draw all the images in a single view instead of using multiple subviews. There's a nice writeup on using it at Cocoa Is My Girlfriend. CATiledLayer makes it easy to build an image out of smaller tiles, display higher resolution images as the user zooms in, and avoid memory problems that come from keeping too much of a large image loaded.
this is happening because you are using different views (here uiimageview). Since they are not part of the same fabric during any animation or change in view hierarchy there is a chance that the gap between them would be visible.
This is a very common problem in graphics programming. The way to fix this problem is to have one single view and add these uiimageviews as sub-layers to this view. That way all the imageviews are part of the same fabric and the gap would not be visible.
I did not post any code but then so did you ;)
I'm new to objective-c and iOS development.
I need an iPad application to display some images and designs (draw) over its, but the design needs be done in a separate image. My idea is use two overlapping UIImageViews, the first one is the images that I want to see, and the second one is an image with transparent background where I will draw some things with finger. All of this is OK and i have implemented, but I need that the zoom be enabled to tow images in the same time. When I'm zooming, the tow images need be resized at the same time.
The scroll needs to work to the images at the same time too.
How can I do this?
Somebody help me!
The two UIImageViews you are overlapping should be subviews of the same UIView.
Then, apply scrolling and zooming to the base UIView, and it will affect also the subviews.
If you haven't added the two UIImageViews to a UIView, then you can do that like this:
[view addSubview:imageView1];
[view addSubview:imageView2];
I'm making a PDF reader that looks like a real book.
I have a UIImageView inside a scrollview as the book's background (imagine an open book with empty pages). The UIImageView's layer has 2 sublayers each positioned over each page, CATiledLayers that render PDF content.
I have 2 UIViews whose layer uses an image as its contents. When I hit a button to turn the page, I take the CATiledLayer attached to the background and remove him but then add him to the UIView's layer as a sublayer. This UIView's layer animates a page turning, and with it animates that PDF page. I create a new PDF page and put it where the old one used to be.
So now there is a PDF page as a sublayer on the background UIImageView, and a UIView overtop of that with a PDF page as a sublayer. For some reason the PDF on the page underneath is visible during the animation. It should not be visible because the turning page should be obstructing it. Question is, why is that happening?
I just had to change the zPosition property of the UIView's layers to a really high number like 10000. I had it set to 0.1 initially but that wasn't enough. Then the compositing worked again.