How do I create a bouncing popover animation like this? - ios

I want to create an animated popover bubble like the one below. With the same expanding/contracting bounce animation. Does anyone know how to go about this? Is is just a UIView with animation? What animation effect is this? Any pointers on how to go about this would be really appreciated. Thanks!

You can use the
Obj-C:
animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:animations completion: method like this:
UIView *animationView = [[UIView alloc] initWithFrame:CGRectMake(50, 90, 100, 50)];
animationView.backgroundColor = [UIColor redColor];
animationView.transform = CGAffineTransformMakeScale(0, 0);
[self.view addSubview:animationView];
[UIView animateWithDuration:0.3
delay:0
usingSpringWithDamping:0.5
initialSpringVelocity:5
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
animationView.transform = CGAffineTransformIdentity;
}
completion:nil];
Swift:
var animationView: UIView = UIView(frame: CGRectMake(50, 90, 100, 50))
animationView.backgroundColor = UIColor.redColor()
animationView.transform = CGAffineTransformMakeScale(0, 0)
self.view!.addSubview(animationView)
UIView.animateWithDuration(0.3, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 5, options: .CurveEaseInOut, animations: {() -> Void in
animationView.transform = CGAffineTransformIdentity
}, completion: { _ in })

i think it is UIPopoverPresentationController.
sample:
-(void)showPopover:(UIBarButtonItem*)sender{
if(!_btnController){
_btnController = [[ButtonsViewController alloc] init];
_btnController.delegate = self;
}
if (_popover == nil) {
_btnController.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *pc = [ _btnController popoverPresentationController];
pc.barButtonItem = sender;
pc.permittedArrowDirections = UIPopoverArrowDirectionAny;
pc.delegate = self;
[self presentViewController: _btnController animated:YES completion:nil];
} else {
//The color picker popover is showing. Hide it.
[_popover dismissPopoverAnimated:YES];
_popover = nil;
}}

Related

How to make the tabbar custom animation only occur for a certain view controller?

I have a custom animation for when the tabs are selected, but instead I want that animation to only occur for when a certain tab is clicked. I am guessing it has to do with the instantiation of the toView. Error http://puu.sh/n5VuA/c3e886957e.png
class TransitioningObject: NSObject, UIViewControllerAnimatedTransitioning {
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
// Get the "from"nd "to" views
let fromView : UIView = transitionContext.viewForKey(UITransitionContextFromViewKey)!
let toView : UIView = transitionContext.viewForKey(UITransitionContextToViewKey)!
transitionContext.containerView()!.addSubview(fromView)
transitionContext.containerView()!.addSubview(toView)
//The "to" view with start "off screen" and slide left pushing the "from" view "off screen"
toView.frame = CGRectMake(toView.frame.width, 0, toView.frame.width, toView.frame.height)
let fromNewFrame = CGRectMake(-1 * fromView.frame.width, 0, fromView.frame.width, fromView.frame.height)
UIView.animateWithDuration(transitionDuration(transitionContext), animations: { () -> Void in
toView.frame = CGRectMake(0, 0, 320, 560)
fromView.frame = fromNewFrame
}) { (Bool) -> Void in
transitionContext.completeTransition(true)
}
}
func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
return 0.35
}
}
This is the view controller code
override func viewDidLoad() {
super.viewDidLoad()
let animatedTransitioningObject = TransitioningObject()
animatedTransitioningObject.animateTransition(UIViewControllerContextTransitionin) //I get an error here
// Do any additional setup after loading the view.
}
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
UIViewController* toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIViewController* fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
[[transitionContext containerView] addSubview:toViewController.view];
toViewController.view.alpha = 0;
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
fromViewController.view.transform = CGAffineTransformMakeScale(0.1, 0.1);
toViewController.view.alpha = 1;
} completion:^(BOOL finished) {
fromViewController.view.transform = CGAffineTransformIdentity;
[transitionContext completeTransition:![transitionContext transitionWasCancelled]];
}];
}
Is how your Animation function should look.
Also if You want a pod that does this for you I would suggest checking out this pod
https://github.com/Ramotion/animated-tab-bar

How to animate a floating UIView in ObjectiveC

I am trying to have a UIView animate as a floating object, or as a Balloon :D
The UIView is in the middle of the screen, and I want it to keep floating randomly around its first initiated spot. Not across the screen or anything like that, just floating in the area of 5 pixels around it.
Any suggestions? :D
I tried this:
[UIView animateWithDuration:0.1
delay:0.0
options: UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction
animations:^{
myCircleUIView.transform = CGAffineTransformMakeTranslation([self randomFloatingGenerator], [self randomFloatingGenerator]);
}
completion:NULL];
randomFloatingGenerator generates a number between -5 and 5. Problem is, it only executes once, and keeps repeating with the same random values.
EDIT1:
Now I have tried This
-(void)animationLoop{
[UIView animateWithDuration:1.0
animations: ^{ myCircleUIView.transform = CGAffineTransformMakeTranslation([self randomFloatingGenerator], [self randomFloatingGenerator]); }
completion:
^(BOOL finished) {
[UIView animateWithDuration:1.0
animations:^{ myCircleUIView.transform = CGAffineTransformMakeTranslation(0,0);
}
completion:
^(BOOL finished) {[self animationLoop];}];
}];
But it is still not working, the animation is.... Cracky... I think I am doing some stupid mistake that I need a second set of eyes to help me with.
EDIT2:
Fixed it.
-(void)animationLoop{
CGPoint oldPoint = CGPointMake(myCircleUIView.frame.origin.x, myCircleUIView.frame.origin.y);
[UIView animateWithDuration:1.0
animations: ^{ myCircleUIView.frame = CGRectMake(myCircleUIView.frame.origin.x + [self randomFloatingGenerator], myCircleUIView.frame.origin.y + [self randomFloatingGenerator], myCircleUIView.frame.size.width, myCircleUIView.frame.size.height); }
completion:
^(BOOL finished) {
[UIView animateWithDuration:1.0
animations:^{ myCircleUIView.frame = CGRectMake(oldPoint.x, oldPoint.y, myCircleUIView.frame.size.width, myCircleUIView.frame.size.height);}
completion:
^(BOOL finished) {[self animationLoop];}];
}];
}
Thanks for the help anyone.
EDIT 3:
Someone posted an enhanced code.
#Shamy's solution, improved, fixed and CPU safe.
-(void)animateFloatView:(UIView*)view{
// Abort the recursive loop
if (!view)
return;
CGPoint oldPoint = CGPointMake(view.frame.origin.x, view.frame.origin.y);
[UIView animateWithDuration:0.6
animations: ^{ view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y - 15, view.frame.size.width, view.frame.size.height); }
completion:
^(BOOL finished) {
if (finished) {
[UIView animateWithDuration:0.6
animations:^{ view.frame = CGRectMake(oldPoint.x, oldPoint.y, view.frame.size.width, view.frame.size.height);}
completion:
^(BOOL finished2) {
if(finished2)
[self animateFloatView:view];
}];
}
}];
}
Whenever you want to stop the animation (necessary when leaving the View Controller), call the function using nil, as this:
[self recursiveFloatingAnimation:nil];
Not stoping the animation will cause the recursive loop to run infinitely and overwhelm the CPU stack.
Swift 4
UIView.animate(withDuration: 0.6, delay: 0.1, options: [.autoreverse, .repeat], animations: {
self.frame = CGRect(x: self.frame.origin.x, y: self.frame.origin.y - 15, width: self.frame.size.width, height: self.frame.size.height)
},completion: nil )
It will behave in that way. As you are repeating the animation not the function. So it will repeat same animation every time you set at first call. Do it like:
#interface AAViewController ()
#property (nonatomic, strong) UIView * floatingView;
#end
#implementation AAViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_floatingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
[_floatingView setBackgroundColor:[UIColor redColor]];
[self.view addSubview:_floatingView];
[self circleUIViewFloating];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Circle UIView floating
- (void) circleUIViewFloating {
[UIView animateWithDuration:2.0
animations:^{
_floatingView.transform = CGAffineTransformMakeTranslation([self randomFloatingGenerator : 270], [self randomFloatingGenerator:480]);
} completion:^(BOOL finished) {
[self circleUIViewFloating];
}];
}
- (int) randomFloatingGenerator : (int) max{
return arc4random() % max;
}
Here is complete running project for this.
You can achieve the hovering or floating effect using CABasicAnimation.
You will have to include the QuartzCore framework to use this.
Swift 4.2:
import QuartzCore
let hover = CABasicAnimation(keyPath: "position")
hover.isAdditive = true
hover.fromValue = NSValue(cgPoint: CGPoint.zero)
hover.toValue = NSValue(cgPoint: CGPoint(x: 0.0, y: -5.0))
hover.autoreverses = true
hover.duration = 0.8
hover.repeatCount = Float.infinity
myCustomView.layer.add(hover, forKey: "hoverAnimation")
Make sure to remove the animation when the view is no longer being shown.
override func viewWillDisappear(_ animated: Bool) {
// Stop animating when view is going to disappear
myCustomView.layer.removeAllAnimations()
}
-(void)animationLoop{
CGPoint oldPoint = CGPointMake(myCircleUIView.frame.origin.x, myCircleUIView.frame.origin.y);
[UIView animateWithDuration:1.0
animations: ^{ myCircleUIView.frame = CGRectMake(myCircleUIView.frame.origin.x + [self randomFloatingGenerator], myCircleUIView.frame.origin.y + [self randomFloatingGenerator], myCircleUIView.frame.size.width, myCircleUIView.frame.size.height); }
completion:
^(BOOL finished) {
[UIView animateWithDuration:1.0
animations:^{ myCircleUIView.frame = CGRectMake(oldPoint.x, oldPoint.y, myCircleUIView.frame.size.width, myCircleUIView.frame.size.height);}
completion:
^(BOOL finished) {[self animationLoop];}];
}];
}
Swift 2.1 Version Here:
func animateFloatView(view: UIView?) {
// Abort the recursive loop
guard let view = view else { return }
let oldPoint: CGPoint = CGPointMake(view.frame.origin.x, view.frame.origin.y)
UIView.animateWithDuration(0.6, animations: {() -> Void in
view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y - 15, view.frame.size.width, view.frame.size.height)
}, completion: {(finished: Bool) -> Void in
if finished {
UIView.animateWithDuration(0.6, animations: {() -> Void in
view.frame = CGRectMake(oldPoint.x, oldPoint.y, view.frame.size.width, view.frame.size.height)
}, completion: {(finished2: Bool) -> Void in
if finished2 {
self.animateFloatView(view)
}
})
}
})
}
Swift 3.1:
func animateFloatView(_ view: UIView?) {
guard let view = view else { return }
let oldYCoordinate = view.center.y
UIView.animate(withDuration: 0.6, animations: {
view.center.y -= 15
}, completion: { _ in
UIView.animate(withDuration: 0.6, animations: {
view.center.y = oldYCoordinate
}, completion: { _ in
self.animateFloatView(view)
})
})
}

iOS: swipe gesture to load different data within same controller

In my application I'm trying to implement a functionality (similar to calendar where month changes within same view) something like if current view shows the news of current day (today) then if user swipe right, it should show the next day news and on swipe left it should show previous day news.
I have so far
a single NewsViewController which shows the today news in table view
On other topics many suggest to use libraries like on this question Tom suggests Handling a view controller that slides in with either way swipe
I am new to IOS development and have no idea how to do it, any help will be greatly appreciated.
So you can try pulling data in any of the gesture methods using this cod here https://stackoverflow.com/a/20596933/1307844
Your answer is totally how you implement your gesture methods.
I found the solution and here is my code snippets...
ViewDidLoad:
UISwipeGestureRecognizer *oneFingerSwipeLeft = [[UISwipeGestureRecognizer alloc]
initWithTarget:self
action:#selector(oneFingerSwipeLeft:)];
[oneFingerSwipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[viewContent addGestureRecognizer:oneFingerSwipeLeft];
UISwipeGestureRecognizer *oneFingerSwipeRight = [[UISwipeGestureRecognizer alloc]
initWithTarget:self
action:#selector(oneFingerSwipeRight:)];
[oneFingerSwipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
[viewContent addGestureRecognizer:oneFingerSwipeRight];
oneFingerSwipeLeft:
- (void)oneFingerSwipeLeft:(UITapGestureRecognizer *)recognizer {
newsList = [[NSMutableArray alloc] init];
//to animate the view as new view is loaded
[UIView animateWithDuration:0.1 animations:^{
viewContent.frame = CGRectMake( -viewContent.frame.size.width, viewContent.frame.origin.y , viewContent.frame.size.width, viewContent.frame.size.height);
[self loadData];
} completion:^(BOOL finished) {
viewContent.frame = CGRectMake( viewContent.frame.size.width,viewContent.frame.origin.y, viewContent.frame.size.width, viewContent.frame.size.height);
[UIView animateWithDuration:0.3 animations:^{
viewContent.frame = CGRectMake(0.0, viewContent.frame.origin.y, viewContent.frame.size.width, viewContent.frame.size.height);
}];
}];
selectedDay++;
[self fetchDataFromWeb];
}
oneFingerSwipeRight:
- (void)oneFingerSwipeRight:(UITapGestureRecognizer *)recognizer {
newsList = [[NSMutableArray alloc] init];
//to animate the view as new view is loaded
[UIView animateWithDuration:0.1 animations:^{
viewContent.frame = CGRectMake( viewContent.frame.size.width, viewContent.frame.origin.y , viewContent.frame.size.width, viewContent.frame.size.height);
[self loadData];
} completion:^(BOOL finished) {
viewContent.frame = CGRectMake( -viewContent.frame.size.width,viewContent.frame.origin.y, viewContent.frame.size.width, viewContent.frame.size.height);
[UIView animateWithDuration:0.3 animations:^{
viewContent.frame = CGRectMake(0.0, viewContent.frame.origin.y, viewContent.frame.size.width, viewContent.frame.size.height);
}];
}];
selectedDay--;
[self fetchDataFromWeb];
}
Thanks to #BalramTiwari for valuable suggestion.
Here is IceFish's answer in swift:
override func viewDidLoad() {
super.viewDidLoad()
let swipeRight = UISwipeGestureRecognizer(target: self, action: "respondToSwipeGesture:")
swipeRight.direction = UISwipeGestureRecognizerDirection.Right
self.view.addGestureRecognizer(swipeRight)
let swipeLeft = UISwipeGestureRecognizer(target: self, action: "respondToSwipeGesture:")
swipeLeft.direction = UISwipeGestureRecognizerDirection.Left
self.view.addGestureRecognizer(swipeLeft)
and the responder:
func respondToSwipeGesture(gesture: UIGestureRecognizer) {
if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case UISwipeGestureRecognizerDirection.Left:
UIView.animateWithDuration(0.1, animations: {
let myFrame = self.view.frame
self.view.frame = CGRectMake(-myFrame.size.width, myFrame.origin.y , myFrame.size.width, myFrame.size.height)
}, completion: {_ in
let myFrame = self.view.frame
self.view.frame = CGRectMake(myFrame.size.width, myFrame.origin.y , myFrame.size.width, myFrame.size.height)
UIView.animateWithDuration(0.3, animations: {
let myFrame = self.view.frame
self.view.frame = CGRectMake(0.0, myFrame.origin.y , myFrame.size.width, myFrame.size.height)
}, completion: nil)
})
// do left action here
case UISwipeGestureRecognizerDirection.Right:
UIView.animateWithDuration(0.1, animations: {
let myFrame = self.view.frame
self.view.frame = CGRectMake(myFrame.size.width, myFrame.origin.y , myFrame.size.width, myFrame.size.height)
}, completion: {_ in
let myFrame = self.view.frame
self.view.frame = CGRectMake(-myFrame.size.width, myFrame.origin.y , myFrame.size.width, myFrame.size.height)
UIView.animateWithDuration(0.3, animations: {
let myFrame = self.view.frame
self.view.frame = CGRectMake(0.0, myFrame.origin.y , myFrame.size.width, myFrame.size.height)
}, completion: nil)
})
// do right action here
default:
break
}
}
}

Setting the initial values of a UIView animation

I run this code when a swipe event is fired, it shows an arrow zooming in while fading out, as you see I set the location of the image to be the same location as where the swipe is, but it only starts from where the previous touch was(set in the completion block). But at the start of the method I set update the location so why is it animating from the location of the previous touch?
static bool isAnimating;
- (void)animateImageZoom: (UIImageView *)imageView startingAtLocation:(CGPoint)location inDirection: (FadeDirection)direction
{
if (!isAnimating) {
CGRect previousFrame = imageView.frame;
imageView.frame = CGRectMake(location.x, location.y, previousFrame.size.width, previousFrame.size.height);
imageView.hidden = NO;
[UIView animateWithDuration:0.6f
delay:0.3f
options:UIViewAnimationOptionBeginFromCurrentState
animations:^(void) {
isAnimating = YES;
imageView.alpha = 0;
// ZOOM
if (direction == fadeLeft) {
imageView.frame = CGRectMake(location.x,
location.y, 256, 256);
} else if (direction == fadeRight) {
imageView.frame = CGRectMake(location.x,
location.y, 256, 256);
}
}
completion:^(BOOL finished) {
isAnimating = NO;
imageView.frame = CGRectMake(location.x, location.y, previousFrame.size.width, previousFrame.size.height);
imageView.hidden = YES;
imageView.alpha = 0.8f;
}];
}
}

change color navigation controller in a popover

I'm having a problem with trying to change the colour of my navigation controller inside my popoverController.
I'm trying to do something like this:
if (self.popoverController == nil) {
ArtistsViewController *artistsViewController =
[[ArtistsViewController alloc]
initWithNibName:#"ArtistsViewController"
bundle:[NSBundle mainBundle]];
artistsViewController.navigationItem.title = #"Artists";
UINavigationController *navController =
[[UINavigationController alloc]
initWithRootViewController:artistsViewController];
UIPopoverController *popover =
[[UIPopoverController alloc]
initWithContentViewController:artistsViewController.navigationController];
artistsViewController.navigationController.navigationBar.tintColor=[UIColor greenColor];
popover.delegate = self;
[artistsViewController release];
[navController release];
self.popoverController = popover;
[popover release];
}
[self.popoverController
presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
but it doesn't work. any suggestions?
////////////////////////////////////////
////////////**SOLUTION**////////
////////////////////////////////////////
I'm gonna edit this post because i solved my problem and I think could be helpful share my solution here:
first of all, follow this sample:
http://mobiforge.com/designing/story/using-popoverview-ipad-app-development
When It is done go to step two.
The second step will be add a new popoverBackgroundViewClass:
Add new file in your project Objective class and call it 'CustomPopoverBackgroundView'
///////////////////////////////////////////////
////// CustomPopoverBackgroundView.h /////////
///////////////////////////////////////////////
#import < UIKit/UIKit.h >
#import < UIKit/UIPopoverBackgroundView.h >
#interface CustomPopoverBackgroundView : UIPopoverBackgroundView{
UIPopoverArrowDirection direction;
CGFloat offset;
}
#end
//////////////////////////////////////////////
////// CustomPopoverBackgroundView.m /////////
//////////////////////////////////////////////
#import "CustomPopoverBackgroundView.h"
#implementation CustomPopoverBackgroundView
- (void)layoutSubviews {
[super layoutSubviews];
CGFloat fullHeight = self.frame.size.height;
CGFloat fullWidth = self.frame.size.width;
CGFloat startingLeft = 0.0;
CGFloat startingTop = 0.0;
CGFloat arrowCoord = 0.0;
UIImage *arrow;
UIImageView *arrowView;
switch (self.arrowDirection) {
case UIPopoverArrowDirectionUp:
startingTop += 13.0;
fullHeight -= 13.0;
//the image line.png will be the corner
arrow = [UIImage imageNamed:#"line.png"];
arrowCoord = (self.frame.size.width / 2) - self.arrowOffset;
arrowView = [[[UIImageView alloc] initWithFrame:CGRectMake(arrowCoord, 0, 13.0, 13.0)] autorelease];
break;
case UIPopoverArrowDirectionDown:
fullHeight -= 13.0;
arrow = [UIImage imageNamed:#"line.png"];
arrowCoord = (self.frame.size.width / 2) - self.arrowOffset;
arrowView = [[[UIImageView alloc] initWithFrame:CGRectMake(arrowCoord, fullHeight, 13.0, 13.0)] autorelease];
break;
case UIPopoverArrowDirectionLeft:
startingLeft += 13.0;
fullWidth -= 13.0;
arrow = [UIImage imageNamed:#"line.png"];
arrowCoord = (self.frame.size.height / 2) - self.arrowOffset;
arrowView = [[[UIImageView alloc] initWithFrame:CGRectMake(0, arrowCoord, 13.0, 13.0)] autorelease];
break;
case UIPopoverArrowDirectionRight:
fullWidth -= 13.0;
arrow = [UIImage imageNamed:#"line.png"];
arrowCoord = (self.frame.size.height / 2) - self.arrowOffset;
arrowView = [[[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width-13.0, arrowCoord, 13.0, 13.0)] autorelease];
break;
}
//this image will be your background
UIImage *bg = [[UIImage imageNamed:#"lineBack.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(8.0, 8.0, 8.0, 8.0)];
UIImageView *imageView = [[[UIImageView alloc] initWithFrame:CGRectMake(startingLeft, startingTop, fullWidth, fullHeight)] autorelease];
[imageView setImage:bg];
[arrowView setImage:arrow];
[self addSubview:imageView];
[self addSubview:arrowView];
}
- (CGFloat) arrowOffset {
return offset;
}
- (void) setArrowOffset:(CGFloat)arrowOffset {
offset = arrowOffset;
[self setNeedsLayout];
}
- (UIPopoverArrowDirection)arrowDirection {
return direction;
}
- (void)setArrowDirection:(UIPopoverArrowDirection)arrowDirection {
direction = arrowDirection;
[self setNeedsLayout];
}
+ (CGFloat)arrowHeight {
return 30.0;
}
+ (CGFloat)arrowBase {
return 30.0;
}
+ (UIEdgeInsets)contentViewInsets {
return UIEdgeInsetsMake(30.0, 30.0, 30.0, 30.0);
}
#end
Third step:
When It is done add this line in 'PopOverExample1ViewController.m':
import the new class:
#import " CustomPopoverBackgroundView.h "
-(IBAction) showMovies:(id) sender {
if (self.popoverController == nil) {
MoviesViewController *movies =
[[MoviesViewController alloc]
initWithNibName:#"MoviesViewController"
bundle:[NSBundle mainBundle]];
UIPopoverController *popover =
[[UIPopoverController alloc] initWithContentViewController:movies];
popover.delegate = self;
[movies release];
//THIS IS THE LINE THAT YOU HAVE TO ADD
popover.popoverBackgroundViewClass=[CustomPopoverBackgroundView class];
self.popoverController = popover;
[popover release];
}
[self.popoverController
presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
-(IBAction) btnShowMovies:(id) sender {
if (self.popoverController == nil) {
MoviesViewController *movies =
[[MoviesViewController alloc]
initWithNibName:#"MoviesViewController"
bundle:[NSBundle mainBundle]];
UIPopoverController *popover =
[[UIPopoverController alloc] initWithContentViewController:movies];
popover.delegate = self;
[movies release];
//THIS IS THE LINE THAT YOU HAVE TO ADD
popover.popoverBackgroundViewClass=[CustomPopoverBackgroundView class];
self.popoverController = popover;
[popover release];
}
CGRect popoverRect = [self.view convertRect:[btn frame]
fromView:[btn superview]];
popoverRect.size.width = MIN(popoverRect.size.width, 100);
[self.popoverController
presentPopoverFromRect:popoverRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
Alright!!! Thats all! If someOne needs help just let me know.
Best wishes!
override func viewDidAppear(_animated: Bool){
let navigationBar = self.navigationController?.navigationBar
navigationBar?.tintColor = UIColor(colorLiteralRed: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
the color of the button bar
navigationBar?.barStyle = UIBarStyle.black
the style bar
navigationBar?.barTintColor = UIColor(colorLiteralRed: 0.89, green: 0.55, blue: 0.69, alpha: 1.0)
the color of the bar
let imageView(frame: CGRect(x: 0, y: 0, width: 250, height: 80))
imageView.contentMode = .scaleAspectFit
}
image bar
all the code
override func viewDidAppear(_animated: Bool) {
let navigationBar = self.navigationController?.navigationBar
navigationBar?.tintColor = UIColor(colorLiteralRed: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
navigationBar?.barStyle = UIBarStyle.black
navigationBar?.barTintColor = UIColor(colorLiteralRed: 0.89, green: 0.55, blue: 0.69, alpha: 1.0)
let imageView(frame: CGRect(x: 0, y: 0, width: 250, height: 80))
imageView.contentMode = .scaleAspectFit
}

Resources