Wondering wether it possible to apply Mask of one CALayer to some number of views underneath it? For example, I want to place mask (representing a "hole") in UITableViewCell and apply its effect to UITableView's background so that I can see part of lowest view while dragging UITableViewCell
Related
I'm beginner with collection view,
I need to create cell like this
Can I do it from Storyboard?
I want to add margin of cell = 4 or 5 in the top, bottom, lift and right in iPhones and iPads of all sizes, or I if need to do that programmatically How I can add the contents of the cell like the image above?
There is no "margin" here. There is simply a rectangle with a shadow, and everything else is drawn in front of it. The simplest solution is probably a custom UIView that draws itself as a rectangle with a shadow. Make that the content view's direct subview, and everything else in the cell is a subview of that. The inset of the rectangle-with-shadow within the cell's content view can be determined by autolayout (and the position of all the stuff inside it can be determined by autolayout too).
Thus it was trivial for me to obtain this sort of thing:
And of course you can tweak the border color, the background color, and so forth.
I am learning how to use storyboard and i am trying to build a UITableViewCell with grouped style. I tried to put a png file and set it as background for the cell.
My png file is a rectangular image.
When i open it in simulator, I found the first cell corner become a rectangle rather than a round corner cell.
What should i can in order to make the first and last cell to be corner rounded?
This is a know problem when using Grouped TableView.
You can either use the backgroundColor of UITableViewCell or you will have to draw the background by hand and check wether is the first of last in the section and add the rounded corners.
have a look at this post
Try to set the property clippingSubviews of your cells to YES.
The design of the UITableView is something like this:
I want to make my cells with a tiny triangle, like in a comic book. The thing is, how can i add the triangle to the size of my custom cell? The common rectangle size wouldn't work if i want the user to be able to tap that little rectangle.
And how can i make the opposite? I want the triangle to cover the space of another cell, so tapping the little triangle of the first cell, covering part of the second cell's rectangle space, would activate de first one. This is, substracting a little triangle from the cell's space.
Not sure it would work, but building on user697562's comment, you could try the following:
Add a small UIView to the table cell to represent the small triangle
Rotate it using its transform property, making sure that, along with its frame, it will have the proper placement.
Add a UITapGestureRecognizer to the UIView
Add an instance variable to the view to save the indexPath of the cell it's in (or even the above cell, since it will be associated with the above cell). This way when the gesture recognizer is triggered, you know what row you're in.
Write the action method associated with the gesture recognizer to do the same thing as tableView:didSelectRowAtIndexPath: would do for the above cell.
Set the separatorStyle property of the UITableView to UISeparatorStyleNone, so that it won't draw the lines between cells. If this doesn't work just set the separatorColor property to your table cell's background color.
Draw a border along the top & bottom of the cell, accounting for the triangle.
Good luck with it! Let me know whether it works if you try it.
I'd like to have a UIView where the user can select each of the four corners and stretch the view by independently moving them.
How would I implement such a view?
To do this, you will need to subclass UIView and handle touch events manually. When you get a touch event, you will have to do some math and then set the frame of the view to the new size. I'd recommend making the background image a stretchable image using stretchableImageWithLeftCap:topCap. It shouldn't actually be that hard.
I'm developing an iPhone application.
I have a UIView used to augmented reality. I add some UILabel to that UIView dynamically and I want to know if there is a way to know when a UILabel hide another UILabel added on same UIView.
In other words: I'm adding UILabels at the middle of the screen (y position is always the same, x can vary). When I'm going to add another UILabel, I want to know if there is another UILabel at the same position.
Note: A UILabel will have a (x,y) origin position and a height and a width.
Maybe there is a method to know where are "located" subview from a UIView.
Thanks.
If you do not apply any transforms to your views you can use CGRectIntersectsRect functions to views' frames:
if (CGRectIntersectsRect(label1.frame, label2.frame){
// Intersect
}