I am developing an app in IOS 7 and I am setting the custom images for tabbar icons. Here is my code:
UIImage *musicImage = [UIImage imageNamed:#"monitor"];
UIImage *musicImageSel = [UIImage imageNamed:#"11"];
musicImage = [musicImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
musicImageSel = [musicImageSel imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
self.tabBarItem = [[UITabBarItem alloc] initWithTitle:#"Notifications" image:musicImage selectedImage:musicImageSel];
My problem is that when I select any tab in the tabbar the image just appears to enlarge.
I am attaching screen shot for more clarification. I just want the image to be in the tabbar. And also both the images are of 50X50px in size.
Maybe try manipulating imageInset property. For me (5,0,-5,0) were ok - but I didn't use titleLabel
self.tabBarItem = [[UITabBarItem alloc] initWithTitle:#"Notifications"
image:musicImage selectedImage:musicImageSel];
self.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5,0);
Related
I want to add a transition effect between images like fade or anything else.
Here's my code:
-(IBAction)startSlideShow:(id)sender;
{
self.imageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:#"slide01.png"],
[UIImage imageNamed:#"slide02.png"],
[UIImage imageNamed:#"slide03.png"],
[UIImage imageNamed:#"slide04.png"],
[UIImage imageNamed:#"slide05.png"],
nil];
self.imageView.animationDuration = 15.0;
self.imageView.animationRepeatCount = 0;
[self.imageView startAnimating];
}
Try this, I think you looking for this one,.. github.com/jberlana/JBKenBurns
(or)
I found this on someother search, try this too..
http://www.raywenderlich.com/10518/how-to-use-uiscrollview-to-scroll-and-zoom-content
Other simple way to achieve: Steps to achieve
Add all the images in one scroll view.
Enable paging for that scroll view.
Based on the content offset of the scroll view highlight the appropriate dot(indicator in the bottom).
I would like to add an UIImageView to this view. Can anyone help me please?
The problem is the compatibilities for 4/3.5 inch
I tryed this
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, self.view.bounds.size.height)];
[imageView setImage:[UIImage imageNamed:#"test.png"]];
[self.view addSubview:imageView];
but the image comes out of the screen!
Thank you!
Controllers are created with a default size and resized after viewDidLoad. Depending on where you are creating your image view, it could cause you problems
Add this code:
imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Also make sure that you don't have other views that you don't want to step over with your image, like the bottom toolbar
/*enter code here */ UIImage *image = [UIImage imageNamed: #"top-bar.png"];
UIImageView *imageview = [[UIImageView alloc] initWithImage: image];
// set the text view to the image view
self.navigationItem.titleView = imageview;
I am using this code for custom navigation bar but the image is cutting out . Although the image width is same as device width.
Any idea, how to solve this.
The titleView property only covers title area of the navigation not the complete navigation-bar.
I am working on an iPad app where I have a button that generates a popover controller that I am populating with a specific view controller. Here is the button code that generates the UIPopoverController and loads it with a specific view (signUpListAddEditViewController):
-(void)addSignUpList:(id)sender {
signUpListAddEditViewController = [[SignUpListAddEditViewController alloc] init];
popover = [[UIPopoverController alloc] initWithContentViewController:signUpListAddEditViewController];
popover.popoverContentSize = signUpListAddEditViewController.view.frame.size;
[popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
signUpListAddEditViewController.popover = popover;
}
Inside SignUpListAddEditViewController.m, I have several fields and a tableview. One of the fields is a UIButton where I display an image and allow the user to load a new image using this button. Since I am already in a popover, I swap the content controller with the UIImagePickerController. So far, so good.
-(void)takePicture:(id)sender
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[popover setPopoverContentSize:popupScreenSize animated:YES]; // popupScreenSize is a CGSIZE set to 500 x 900
[popover setContentViewController:imagePicker animated:YES];
}
The view is swapped out with the imagePicker with the size remaining the same as the original view and I can see the various picture galleries (Camera Roll, Photo Stream, etc). Here is where it gets strange. As soon as I pick one of the galleries, the view is replaced with a thumbnail view of the pictures in that gallery AND THEN the view resizes to a much narrower width. The images are distorted and nearly impossible to select one of them.
I have tried setting [popover setPopoverContentSize:CGSIZE animated:YES] prior to every access to the popover controller, with everything resizing properly EXCEPT the detailed image view? Any ideas where I can override the thumbnail image gallery view?
Here is the code for the didFinishPickingMediaWithInfo method where I again override the content size:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
[thisList setThumbnailDataFromImage:image];
[popover setPopoverContentSize:popupScreenSize animated:YES];
[popover setContentViewController:self animated:YES];
listImageButton.imageView.image = image;
}
I'm a first time programmer and i'm trying to make a soundboard app. Its not finished yet and it is pretty basic. I have a main menu with one button. When this button is pressed, a different background image should appear along with a back button. The image does not change. here is the code:
-(IBAction)redgradient {
UIImage *img = [UIImage imageNamed:#"redgradient.jpg"];
[imageView setImage:img];
}
-(IBAction)redgradient2 {
UIImage *img = [UIImage imageNamed:#"redgradient2.png"];
[imageView setImage:img];
}
I have mentioned the IBActions in the H file and used an IBOutlet of ImageView. Help is appreciated.
Here's a more simple way to do that, test if this works better:
-(IBAction)redgradient {
imageView.image = [UIImage imageNamed:#"redgradient.jpg"];
}
-(IBAction)redgradient2 {
imageView.image = [UIImage imageNamed:#"redgradient2.png"];
}
Check if the images ends on .jpg or .png if that is the problem.
Here are a few things to check:
The image files have been added to the project.
The image names are exactly as they appear in the project (case sensitive and correct format).
The connections are properly established in the IB.