I'm implementing the a viewController to enter text and images (very similar to Facebook's "Status" entry) and I have most of it complete, however, the last piece isn't working correctly.
The user can select an image and key-in textual data. As more text are added, the images get pushed down. I implemented this by adding UIImageView as subview of UIView, then add UIView as subview of UITextView. They stack up like this:
Top: UIImageView
Middle: UIView
Bottom: UITextView
When I key-in long enough text that it pushes the images down, the images do not stay visible inside the UITextView. I can still see the images if I drag the screen-up, but as soon as I let go, the images bounces down and can't be seen. How do I fix this? Thanks.
You do the followings for this.
1- Have a UIimageView and set your image
2- Draw your UITextview on exact location of image. Means (x,y,w,h) equals
3-Set UItextView background color CLEAR.
and CHEERS
Related
NOTE: I can't use UIView's maskView method because that changes the UITextView into a single view. My UITextViews are movable via pan, rotate and pinch gestures and maskView doesn't allow that.
Please look at these 2 pictures to understand what I am trying to achieve:
The first picture is what I already have. The background image of the tiger is a UIImageView. On top, I have 2 UITextViews "Love" and "Yolo". There can be more than 2 UITextViews too. I am trying to convert the first to look like the second one. Basically I want the UITextViews to show transparent see-through text. Everything which is not UITextView gets grey color.
Now note the 3rd image where the 2 UITextViews overlap each other. When overlapping, I want it both the UITextViews to be see-through like this image:
How can I achieve this effect? I am looking for guidelines on how this can be achieved.
I have a login table that give to my users many forms to create a account, inside my table I have a cell with a UILabel, all I'm trying to do is create two horizontal lines around the UILabel like this image below:
Example of image
That image have two horizontal lines around the label OR, what better way to do this? And how I can do this?
You can create lines out of very thin UIViews with a background color of gray or black. In storyboard, drag a UIView in front of the UILabel in the cell, size according to your preferences, and copy it to make one after the label as well.
I have a UITableView with rows.
Each row has a small UIImageView aligned to the right (a "bookmark" icon)
The UIimageView has a UITapGestureRecognizer associated.
cell.favoritedImageView.userInteractionEnabled = true
cell.favoritedImageView.addGestureRecognizer(gestureRecognizer)
The problem is that to actually tap it with the finger (in a real device), you have to use the tip of the finger and be very accurate, because the image is small.
If you miss tapping the imageView, the cell is tapped (didSelectRowAtIndexPath) and you end up executing a show-segue to another view, so you have to go back and try again (not cool)
Question: what is the best way to solve this? I want it to be easy to be tapped.
I have some ideas:
Create a larger image with transparent surrounding (ie: crop out with transparent background) -- downside is that I also use this image in other views, in which is not tappable, so I'd have to create two versions of the image
Put the image inside a UIView and make the UIView big and tappable instead of the UIImageView
Add padding to the UIImageView (will this work? or the padding is not recognized in the UITapGestureRecognizer?)
Per your own suggestion, you should create a transparent view that is much larger and attach the UITapGestureRecognizer to the view and then nest your smaller image within the view. That way appearances are the same, but you handle a much larger area for the tap to be recognized with selecting the cell.
I have a very specific requirement to fulfil.
Lets say this is my original background image (on the right).
This is how my image should be on the screen by default.
And this is how it should be when I do a "pull down" gesture on the UITableView.
I want to set an image (shown above) as a view's background. A UITableView to be specific.
NOTE: Image size is more than the view size.
When I try to pull down the view beyond the bounds of the view, the image should continue to show up and should not break. With the current implementation the image from the bottom part shows up.
Any ideas how I can achieve this? Pardon me if the solution is obvious.
You can do this by only one line of code
[yourView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"YourBGImgName.png"]]];
OR Alternately
put one UIScrollView and set it's background color with above way and you can find your background repeating when you scrolling your scrollView.
Set the top part as the background for a UITableViewHeaderFooterView in the header and do the same for the footer. Then set a negative inset for your tableView.
Something like
[self.tableView setContentInset:(UIEdgeInsets){-headerHeight, 0, -footerHeight, 0}];
I have a UITextView with approx 100 lines(for testing purpose its static) which scrolls fine but when i try to scroll from approx 150 its from the bottom i can not scroll. That means it lets me scroll from only certain area of the textview. for example see the image below. If i try to select and scroll above 3 line from top, i can scroll but below 3rd line, It won't let me scroll. I went through documentation but couldn't find anything that makes sense.
Try resizing the frame of your UITextView so it does not overlap the UITabBarView. If you create this in interface builder, you can resize it there.
if there is some area that is not taking ui touches, thAT means, your UITextView is being overlapped by another view. try:
[self.view bringSubviewToFront:textView];
also think about Enrico's answer.
Put Background color for TextView. It will give you extact idea of TextView Complete framing and is it sub view of background or foreground.