How to set growup effect to play video inside that view? - objective-c

I want to create a application in iPad. like "Showyou" in iTunes
For that i need to set growup effect of the view when user touch the video thumnail image and hide with animation at its place when user touch outside the view like popover in ipad.

I haven't used the ShowYou app but it seems like you need an animation to grow/shrink a view and possibly move it. If that's the case try this
// to make it grow in this case 1.5 and move it to a into position in this case 100, 100
[UIView animateWithDuration:_animationDuration
animations:^{
CGAffineTransform transform = CGAffineTransformMakeScale(1.5f, 1.5f);
testView.transform = CGAffineTransformTranslate(transform, 100.0f, 100.0f);
}
];
// make it go back
[UIView animateWithDuration:_animationDuration
animations:^{
someView.transform = CGAffineTransformIdentity;
}
];
You might want to use animateWithDuration:delay:options:animations:completion: so that you can add code to do something after the animation is done. Hopefully that's what you are looking for. :)

Related

I want to open UIView just like facebook opens image in fullscreen in objective c

I have tried a lot but not getting any solution . I have referd https://github.com/xmartlabs/XLMediaZoom .
In terms of third party libraries, https://www.cocoacontrols.com/controls/vertigo seems to do what you want? You could look on https://www.cocoacontrols.com/ for others, like https://www.cocoacontrols.com/controls/exphotoviewer.
If you want to implement this yourself, you could look at custom transitions which became possible in iOS 7, e.g. when you tap a UIView, you transition to a UIViewController which covers the fullscreen with the image.
Actually that being said you could just animate your UIView to cover the fullscreen :p,
[UIView animateWithDuration:0.5 delay:0 options:0 animations:^{
// (flag) ? set frame fullscreen : set frame normal
// or even better create and modify constraints with Masonry
// https://github.com/SnapKit/Masonry :)
}];

Drag And Swap Two UIScrollViews (Hover & Swap Effect)

I am creating a photo editor in my app and working on a multiple picture layout option.
Currently when the user takes a picture, I display their image in UIImageView nested in a UIScrollView. The reason I nest it in a UIScrollView is so I can pan and zoom.
In the situation where the user selects duo layout mode, the app puts 2 images side by side (so 2 UIScrollViews).
If they hold a finger on one UIScrollView I want to raise the UIScrollView up a tad and give it a drop shadow.
I have a long way of doing this, but I was curious if there was anything in the native libraries that will let me automatically create this hover effect for dragging a view class.
Thanks
No, there isn't any preexisting functionality for this. You can add shadow and animate a "lift" motion yourself with something like this:
// define dragged somewhere as the UIView subclass of your choosing
dragged.layer.shadowColor = [UIColor blackColor].CGColor;
dragged.layer.shadowOffset = CGSizeMake(-2, 2);
dragged.layer.masksToBounds = NO;
dragged.layer.shadowRadius = 4;
dragged.layer.shadowOpacity = .7;
[UIView animateWithDuration:.2 delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{self.draggedPhoto.transform = CGAffineTransformMakeScale(1.2, 1.2);}
completion:nil];

How to get object position and size in UIView objective c

I put UIImageView in my Scene from Object library, and give it an image and defined OUTLET in .h file. Now I want to check its coordinates, or center point, or frame X,Y,Width,Height.
I am using
This
CGRect newFrameSize = CGRectMake(recycleBin.frame.origin.x, recycleBin.frame.origin.y,
recycleBin.frame.size.width, recycleBin.frame.size.height);
or
CGRect newFrameSize = recycleBin.frame;
by using this
NSLog(#"%#", NSStringFromCGRect(newFrameSize));
gives same result that is
2013-01-16 21:42:25.101 xyzapp[6474:c07] {{0, 0}, {0, 0}}
I want its actual position and size when viewcontroller loaded, so when user click on image view it will fadeout by zoom-in towards users and will disappear, and when user tap on reset button, it fadein and zoom-in back to original form (reverse to the previous animation).
Also give me hint, how to perform this animation on UIImageView or any button or label. Thx
Unfortunately, you can't check an item's actual frame as set in IB in -viewDidLoad. The earliest you can check it (that I've found) is by overriding -viewDidAppear:. But, since -viewDidAppear: could be called multiple times throughout the life of the view, you need to make sure you're not saving the frame it's in the modified state.
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if(savedFrame == CGRectZero) {
savedFrame = self.recycleBin.frame;
NSLog(#"Frame: %#", NSStringFromCGRect(savedFrame));
}
}
Where savedFrame is a member variable (or you could make it a property).
From the description of the animation you're wanting, it sounds like adjusting the frame isn't the way to go about it. It sounds like you're wanting to get the effect of the view stretching and fading out (and the reverse when being reset)? If so, some code like this might be more so what you're looking for...
Fade out:
float animationDuration = 2.0f; // Duration of animation in seconds
float zoomScale = 3.0f; // How much to zoom in duration the animation
[UIView animateWithDuration:animationDuration animations:^{
CGAffineTransform transform = CGAffineTransformMakeScale(zoomScale, zoomScale);
self.recycleBin.transform = transform;
self.recycleBin.alpha = 0; // Make fully transparent
}];
And then, to reset the view:
float animationDuration = 2.0f; // Duration of animation in seconds
[UIView animateWithDuration:animationDuration animations:^{
CGAffineTransform transform = CGAffineTransformMakeScale(1.0f, 1.0f);
self.recycleBin.transform = transform;
self.recycleBin.alpha = 1.0; // Make fully opaque
}];
You can play around with the numbers to see if you get the effects you desire. Most animations in iOS are actually extremely simple to do. This code would work for any UIView subclass.
It sounds as if your IBOutlet is not attached to your class.
Open up your view controller header file (if that is where you property declaration is) and look beside the declaration:
Notice how on the first IBOutlet, the circle (to the left of the line number) is filled in. This means that it is connected to your scene. However, the second one is not (the circle is not filled in).

why button cannot move in animation?

I want to click _transitButton to call onTransitButtonDidClick to move _rightView.
The problem is the button cannot do as I set self.transitButton.frame = CGRectMake(0, 0, 30, 20);.
update:
_transitButton original frame is (0,280,30,20)
the result is, the button move from the original frame to (0,0,30,20), but quickly move back to original point.
why it went back?
why and how to solve this issue?
- (IBAction)onTransitButtonDidClick:(id)sender {
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationCurveEaseInOut
animations:^{
[_rightView setFrame:CGRectMake(40,0,320,548)];
[_transitButton setFrame:CGRectMake(0,0,30,20];
}
completion:nil];
}
you are using autolayout in your xib and constraints keep the button in place.
with animation it appears to work because the constraints arent evaluated for animations.
so either turn off AUTOLAYOUT for this xib or modify the appropriate constrains.
(I tried this with a small sample app and that's it.)

GMGridView appears offscreen, but overlaps with onscreen view

I am using a custom controller for transitions (could not use navigation controller due to inherent cycles in project, which would allow the navigation controllers stack to grow unbounded [which I assume would cause memory issues]). I am emulating a navigation controllers sliding animation (when transitioning to new screens) using UIView animateWithDuration:animations:completion:
When a button triggering the transition is pressed, the frame of the new view I want to transition to is set to an offscreen position. In the animation for the transition (UIView animateWithDuration:animations:completion:), the view currently on screen has its frame set to an offscreen position, and the new view is set to an onscreen position.
This is inside my custom controller for transitions:
CGFloat windowWidth = self.mainView.frame.size.width;
CGFloat windowHeight = self.mainView.frame.size.height;
CGRect offScreenLeft = CGRectMake(-1*windowWidth, 0.0, windowWidth, windowHeight);
CGRect onScreen = self.mainView.frame;
CGRect offScreenRight = CGRectMake(windowWidth, 0.0, windowWidth, windowHeight);
if (direction == TransitionDirectionForward)
{
if (dragBackgroundOnscreen){
[self.mainView addSubview:self.backgroundView];
[self.mainView sendSubviewToBack:self.backgroundView];
self.backgroundView.frame = offScreenRight;
}
self.currentViewController.view.frame = offScreenRight;
[UIView animateWithDuration:0.65
animations:^{
oldViewController.view.frame = offScreenLeft;
if (dragBackgroundOffscreen)
self.backgroundView.frame = offScreenLeft;
else if (dragBackgroundOnscreen)
self.backgroundView.frame = onScreen;
self.currentViewController.view.frame = onScreen;
}
completion:^(BOOL finished){
[oldViewController.view removeFromSuperview];
if (dragBackgroundOffscreen)
[self.backgroundView removeFromSuperview];
[oldViewController willMoveToParentViewController:nil];
[oldViewController removeFromParentViewController];
[self.currentViewController didMoveToParentViewController:self];
}];
}
else if (direction == TransitionDirectionBackward)
{
if (dragBackgroundOnscreen){
[self.mainView addSubview:self.backgroundView];
[self.mainView sendSubviewToBack:self.backgroundView];
self.backgroundView.frame = offScreenLeft;
}
self.currentViewController.view.frame = offScreenLeft;
[UIView animateWithDuration:0.65
animations:^{
oldViewController.view.frame = offScreenRight;
if (dragBackgroundOffscreen)
self.backgroundView.frame = offScreenRight;
else if (dragBackgroundOnscreen)
self.backgroundView.frame = onScreen;
self.currentViewController.view.frame = onScreen;
}
completion:^(BOOL finished){
[oldViewController.view removeFromSuperview];
if (dragBackgroundOffscreen)
[self.backgroundView removeFromSuperview];
[oldViewController willMoveToParentViewController:nil];
[oldViewController removeFromParentViewController];
[self.currentViewController didMoveToParentViewController:self];
}];
}
I also want the background (self.backgroundView) to remain static unless moving to a screen that has its own background (i.e. I dont want the background to slide if the new views background is the same background).
I am using TransitionDirectionBackward and TransitionDirectionForward just to differentiate between sliding left and sliding right.
Everything works great, except when transitioning involves a GMGridView. the problem when the Gridviews frame is set to an offscreen frame its really setting its currently selected page's frame to that offscreen frame. Other pages of the gridview are not bounded by this frame, so they can appear on screen even before the transition. I tried setting the frame and bounds property on the GridView's viewcontroller's view, but I can still get a page of the gridview appearing onscreen before the transition animation.
Anyone see a solution to this? I was trying to find a way to clip the view of the GridView during the transition so pages dont appear except for the currently selected page, but havent found anything useful.
UPDATE: I found a possible fix by setting alpha = 0.0 for cells that are visible but shouldnt be (later setting alpha = 1.0 when the transition animation is complete). However, I need to know which cells to do this for. I need a way to access the page that the GMGridView is currently on so I can set the adjacent page's cells to have an alpha of 0.0.
UPDATE: Found a way to get it to work by using myGridView convertPoint:(A cgpoint i found by trial and error to be on the first cell of a page.) fromView:myGridView.window. NOTE: I needed an if/else if to check if i was in lanscape left or landscape right since the window coordinates do not rotate when the device is rotated. with this i was able to get the index of the cell at the point on the screen i had specified and then set the previous page to be transparent until after the transition animation.
I would still like to know if there is a way of "clipping" the gridview so that if the cells could be opaque, but just never displayed....?
I think I over complicated the problem. I was looking for the clipsToBounds method of a UIView (although I could have sworn I tried that before). In any case, its working now!