Trying to mask a UIImage to display UITableViewCell contents behind it while scrolling UITableView in iOS - ios

I am building an application where I have a ruler (that is a UIImage) that I use to scroll a UITableView. My UITableView has UILabels on each cell that display text. When the user leaves the ruler over a cell, the ruler has on it a UILabel that displays the contents of the UITableViewCell that it is over top of. All of this functionality is in place, and is working fine.
What I would like to do is when I scroll the ruler up or down, is to be able to view the contents of the table rows behind it dynamically while "the ruler is moving", so that the user can see right through the ruler. As a concept, I realize that this technique is called "masking", but normally "masking" is done using two images. What I'm trying to do is use a UIImage that has a UILabel on top of it, to display the contents of the rows behind it while it is moving. Can anyone show me how to do this, or point me in the right direction?
Here is an image of what it is I am trying to implement:
If you look at the image that I am using, the ruler image is partially hiding the bottom of the text in the third row, and partially hiding the top of the text in the fourth row. I would like the ruler to display the bottom of the text in row 3, and the top of the text in row 4 rather than hiding it when it is in this transition state.

Related

Syncing Two CollectionViews For Navigation

I’m trying to sync two collection views proportionally for navigation. One of the collection views is menu-like and is at the top, and the second is a larger one below. What I would like is for the top collection view to scroll a distance of the width of one cell (the cells are dynamically sized) when the user scrolls the bottom collection view a distance of the main screen’s width. The closest thing I've seen to this effect would be iOS: Custom top segmented control works as expected only when using debugger. What I would like to change is to have the left most cell in the top menu always selected. In addition, when the user scrolls the bottom collection view the width of the screen, a new cell should Replace the left-most cell in the upper menu and be selected. Any help in Swift would be especially appreciated, but ObjC answers are also welcome.

swiping image using collectionview in swift

I have some images showing on collection view cell. I am swiping it horizontally. I want the next or the previous image to be shown, by swiping it to right or left but it is swiping like the image attached.
My image:
In this image, two images are there.
How to do it so that by swiping one image will come one after another without not more than one image at a time on the screen?
I think I understand what you're asking. You want only 1 photo to show up, and take up the whole screen, and when you swipe it goes to the next image and snaps it into place? This would just be as simple as:
Making sure your UICollectionViewCell width is the same as the collection view's width.
Enabling paging on the collection view. If you are using Storyboard just select your UICollectionView and check the checkbox labeled "Paging Enabled". To do it programmatically you can just set collectionView.isPagingEnabled = true.

UICollectionViewCell Shadow on all four sides

I was wondering want the best way to add drop shadows to a set of collectionviewcells that do not have spaces between them?
Background
Part of my layout has various cells positioned across the screen like a post. It notes and the second half of the layout is structured to look like a tableview except all the cells don't go to the edges there's a bit of padding. So I can't really add a shadow around the collection view itself.
I have added shadows to the cells in the post. It note part which works great because the cells have spaces between them but I'm now struggling with the second half (the tableview looking part) because obviously when you add the shadows to the cells depending on the zIndex you may see the shadow overlapping the below or top cell.
So I was wondering what is the best way to do this?
Should the shadows decoration views underneath the cells?
OR
Should the shadows be attached to the cell and increase the ZIndex for each cell so they appear on different levels hiding the shadow - but that leads to a question on how to do the first cell and have a top shadow?
OR
Should I almost fake it by using an image of a shadow inside the cell itself?
I also have deletion functionality so I need to figure out how to make sure if I delete the first cell, the second cell should then have the top shadow in a nice animated way.
EDIT:
I am trying to create the following view inside the collection view. I have got the layout correct. 1
The green lines are the shadows I have working but the red are the ones I'm having trouble with and the boxes are the different cells.

How to set Table view cell to occupy entire screen?

I am working on a project to get custom news feeds from Bing news. I created a custom table view cell and populated various UI items in it. But I am having a hard time to make it occupy the entire screen, it starts from extreme left and ends on the right, leaving large gap from the right margin as show in the image. Can anyone help me out, how to correctly fix it with a detailed explanation of how constraints work in Table views and Tableview cells.
Here' what it looks like in the simulator
Remove previous constraints and add constraint to your UITableView like as shown in below image.
So you UITableView will have 0 margin from edges.
Create a UITableViewController. Just drag drop a TableViewCell into it. Add identifier for that cell and use it. By default it will occupy the whole screen.
In your case I guess you might have added constraints to UITableView. Here what you should do is pin your UITableView to Top,Bottom,Right & Left or make UITableView's width equal to SuperView.

Is it possible to figure out what part of the cell is visible from inside the cell subclass?

In my cell subclass the user can slide the cell for actions, just like in Mail.app. However, the cells can be much larger than Mail.app, sometimes up to 1,000pt which means it requires the table to be scrolled to read fully.
This means that the normal strategy of simply centering the actions vertically in the cell will not work, as the vertical center could very well not be visible. So I want to display it in the vertical center of the visible area.
Is this possible to do within the UITableViewCell subclass where the sliding action is occurring? Figuring out where the vertical center of the visible area even is?

Resources