Setting UIScrollView Background Image - ios

I have a scrollview that takes up the full display size on a view. I want to set the background to a static image. I don't want to tile it, so I don't think I can use backgroundColor. Also, I don't really want it behind the scroll view (setting the scrollview to transparent) because I want bg to scroll with the scroll view.
Any help would be great. Thanks!

Try setting a tillable image as your background color.
scrollView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"tileableImage.png"]];

Just add a UIImageView that is the same size as the scroll view's content size

When we set image to scrollview as a background then that is scrolled with scrollview. So instead of setting image to background , set image to view
self.view.backgroundColor = UIColor(patternImage: UIImage(named: "bg.jpg")!)

Related

How can I make the background of UICollection view as transparent without making the cells in it transparent in Swift

I have a collection view and of course I also have the cells in it. If in the property inspector I change the alpha of collection view to 0, the cells in it also become transparent. Is there a way to make the background transparent of the collection view only so the image behind it is visible?
using in Swift 3:
collectionView.backgroundColor = UIColor.clear.withAlphaComponent(0)
You can change the cell colour to clear and set the background to nil to see whats underneath the collectionView. Like this:
collectionview.backgroundView = nil;
collectionview.backgroundColor = [UIColor clearColor];
A UICollectionViewCell's background is defaulted to clear. Simply set a background colour for your cells either in interface builder or in a subclass using:
self.backgroundColor = UIColor.WhiteColor()
if you drop collection view opacity to 0 the whole collection view will be invisible. In your case you want to show collection view cell only so collection view cell's background view should be UIColor.clear either collection view background. Programmatically like this
self.collectionView.backgroundView?.backgroundColor = UIColor.clear
self.collectionView.backgroundColor = UIColor.clear
In my case i need to show chat log like this so i used that code
my example case
In the UICollectionView set the background color to clearcolor in the attribute inspector.
Dropping UICollectionView's Opacity to 0 from attribute inspector will make it transperent.
P.S:
Bad practice, but will work.

Get uiview section under uiimageview?

I have an UIView as background, and a UIImageView above it.
What I want to do is fill the UIImageView with the UIView section that is in the back (without the white border)
I tried cropping a snapshot of the background but it doesnt look good. there is always a difference.
Make the background UIView a subview of the UIImageView and then set the property of the UIImageView yourImageView.clipsToBounds = YES
Use CALayer mask. The mask will be the smaller image view, and will be assigned to the background view's mask property.

How to set a background image on a UITableView and have the table view span the full height?

Currently, I am using a UITableViewController. I'm setting a background image on the table view. I have a custom view which contains a segmented control and a search bar that I am setting as the table view header. I'm styling its background to be transparent so that you can see the background image behind it.
Here's what it looks like so far:
However, I would like it to look like this, where the white background color of the table view spans the full height:
How can I achieve this effect?
UIImageView *views = [[UIImageView alloc] initWithFrame:viewFrame];
views.image = [UIImage new];
self.tableView.tableHeaderView = views;
Wouldn't these steps solve your problem ?
remove the tableview background image;
set the tableview background color to white;
add the background image to the table view header instead.

overlapping Views during Push transition

I have a storyboard in which i am pushing one view on top of another view in the navigation controller.(Simple push Segue). I am setting the background of the new view in the viewDidLoad method and using the following code to do so.
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"welcome_bg_pattern"] ];
But during the push animation form one view to the other view i can see both the views overlapping. Can some body can guide me how i can set the background so that i don't have that problem.
Here are the attach imaged
first View
During push Transition. here you can see both the vies are overlapped this will not happen if i just simple set a redColor as background color of the view
Second View
I have also tried by setting the background image in the viewWillAppear
Any help will be great
Instead of set background image of self.view like
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"welcome_bg_pattern"] ];
set background image in UIImageView with set proper frame and add UIImageView as subView of self.view.

setting Transparency to the UITableView

I have a view that contains a scroll view and again that contains a view and then a table view.(this table view has custom cells).
I have a background image for the top most view but the inner most table view background is blocking the image. Tableview shows a white background .
I have to make the background of tableview as transparent so that the image on the view should be visible.
how to do that. Pls help.
Try:
tableView.backgroundView = nil;
tablecell.contentview.backgroundcolor = [UIColor clearColor];
Hope it should help..
You have to set the backgroundview nil before making background as transparent
tableView.backgroundView = nil;
tableView.backgroundColor=[UIColor clearColor];

Resources