I am trying to add a background image to a table view. I am using Xcode and swift.
Use the .backgroundView property on your tableview object and set it with whatever UIImageView you want. UITableView Apple Reference Docs
tableView.backgroundView = UIImageView(image: UIImage(named: "something.png"))
You can also add image like this way also:
tableView.backgroundColor = UIColor(patternImage: UIImage(named: "your_image_name")!)
Add imageView to background layer and set what ever image to that image view .And set table view background color & cell color to clear.
Related
I made a subclass of UIImageView which uses Core Graphics to generate a new image that is cropped to a circle with an optional border. It works fine when I run the app. In Interface Builder, however, the generated image renders properly, but it does so underneath the "no image set" placeholder for a UIImageView. Also, the image property shows up twice in IB, and the new image is only generated if I set the overridden field. If I set the image in the regular UIImageView field, it just acts as though it isn't subclassed. Is this just a bug in IB, or is there a fix?
#IBInspectable override var image : UIImage? {
didSet {
// Make the image a circle
makeCircleImage()
}
}
We are stuck with Apple's IB implementation, I'm afraid. I recommend that you find a workaround to overriding image. You can instead implement prepareForInterfaceBuilder and awakeFromNib and do it there, or have a method of doing this operation once in the draw or layout methods, or have a boolean IBInspectable var that does this operation when set.
I have a embedded containerview inside my viewcontroller that leads to a UIPageController. Then the UIPageController loads images from a 3rd VC controller.
So it just a simple image swipe / image carousel.
What I cant get to work is autolayout on the UIImage. My containerview has a maring top 0 right 0 left 0 and a height of 200pt with aspect ratio set.
Bellow it some other information shows eg title / text etc.
But all images appears zoomed in/croped in the containerview.
So how can I make the images scale and fit inside the container view?
Thanks,
set the image view's contentmode to scale aspect fit to see as much of the image as possible.
imageView.contentMode = .ScaleAspectFit
I want to add a background image behind my table view.
I have my file staticTableControl.m where I populate the table and I have added
-(void)viewDidLoad{
self.tableView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:#"disk2.jpg"]];
[super viewDidLoad];
}
at the top, but the image doesn't load - please can someone advise me what else I need to do?
Thank you
There have been some other questions about background images for tables, but I couldn't find one specifically for this.
A good solution is to change the tableview background color to transparent and add an imageview behind it
I have a View to get and set image from photo gallery.
I want to call the image from another view and set the uiimage as background.
What is the best method to make the image stay as a background like iPhone default background feature?
My codes are modified version from here: http://blog.hanpo.tw/2012/01/uiimagepickercontroller-and-simple.html
The best way is to use a UIImageView :
UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageWithContentOfFile:#"path/of/myImage.png"]]
You can pass the path to your image as an argument and store it or copy the file under the name "background.png" for example, and each time you change it you delete the file and create the new "background.png".
In my app i have an image view in one view controller and a movie player in other view controller.Now i want to display the image or movie in both mode i.e in portrait mode and in landscape mode .How can i define frame for each and how do i notify it when the view changes its position from one to other.
Thanks,
Christy
MPMoviePlayerController.view.frame = CGRectMake(20,20,280,440);
imageView.frame = CGRectMake(0,0,320,480);
and image in UIImageView in center have transparent background
this is for iPhone
Checkout the documentation for UIViewController and look at the Responding to View Rotation Events Methods like: - willRotateToInterfaceOrientation:duration: You can put your code for setting the new frame sizes in those functions along with any notification functions you want. player.view.frame = CGRectMake(x,y,w,h);