IOS facebook PoP first experience, iosfacebook

Source: Internet
Author: User

IOS facebook PoP first experience, iosfacebook

Speaking of pop, I learned a lot. I used the cocopods tool for the first time. Because I am not familiar with the operation, I learned it for a long time yesterday. From installation to running. To help more people learn about pop, I will write a brief introduction to the full version from cocopods to pop animation.

1. Install cocopods. Open the terminal and enter this command: gem sources -- remove https://rubygems.org/wait for a response and then enter: gem sources-a http://ruby.taobao.org/it is best to enter gem sources-l

Check whether


With this, we can install cocopods. Then enter sudo gem install cocoapods in the terminal to download it. At this time, you can have a cup of tea and wait until it is automatically downloaded. After the download is complete, you can use it. Create a project first. Then open the terminal again. First use the command line to enter the folder where I am placing it on the desktop (cd ~ /Desktop/file name) Input touch podfile on the terminal. Then you will see a red arrow pointing to the file. Now you can use the text editor that comes with mac to open it and enter:

Platform: ios, '7. 0'
Pod 'pop', '~> 1.0'

In this case, OK. Then, enter "pod install" in the terminal to download the file. After the download is complete, there will be multiple files in the Q & A folder:


Now you want to open xcworkspace, run it, and you don't have to open the original xocde. After running, check whether there are any errors. If you don't congratulate you, you can continue to do things.

Let's take a look at my code:

# Import "ViewController. h "# import <pop/POP. h> @ interface ViewController () {UIButton * _ btn; UIImageView * _ imageView; BOOL _ isOpened;} @ end @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad]; self. view. backgroundColor = [UIColor whiteColor]; [self createBtn];}-(void) createBtn {_ btn = [UIButton buttonWithType: UIButtonTypeSystem]; _ btn. frame = CGRectMake (100,100,100,100); [_ btn setTitle: @ "wq" forState: UIControlStateNormal]; [_ btn setTitleColor: [UIColor whiteColor] forState: UIControlStateNormal]; _ btn. backgroundColor = [UIColor redColor]; [_ btn addTarget: self action: @ selector (playAction) forControlEvents: UIControlEventTouchUpInside]; [self. view addSubview: _ btn]; _ imageView = [[UIImageView alloc] init]; _ imageView. backgroundColor = [UIColor blueColor]; _ imageView. frame = CGRectMake (100,200,200,200); _ imageView. userInteractionEnabled = YES; // drag UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc] initWithTarget: self action: @ selector (handlePan :)]; [_ imageView addGestureRecognizer: pan]; [self. view addSubview: _ imageView]; // click the gesture UITapGestureRecognizer * gestureForSpring = [[delealloc] init]; [gestureForSpring addTarget: self action: @ selector (changsSize :)]; [self. view addGestureRecognizer: gestureForSpring]; self. navigationItem. rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle: @ "+" style: UIBarButtonItemStyleDone target: self action: @ selector (showPop)];} // void) showPop {if (_ isOpened) {[self hidePop]; return;} _ isOpened = YES; POPSpringAnimation * positionAnimation = [POPSpringAnimation metadata: kPOPViewFrame]; positionAnimation. fromValue = [NSValue valueWithCGRect: CGRectMake (300, 0, 0, 0)]; positionAnimation. toValue = [NSValue valueWithCGRect: CGRectMake (300,100,100,100)]; positionAnimation. springBounciness = 15.0; positionAnimation. springSpeed = 20.0; [_ imageView pop_addAnimation: positionAnimation forKey: @ "frameAnimation"];} // when hiding-(void) hidePop {POPBasicAnimation * positionAnimation = [Audio Encoding: kPOPViewFrame]; positionAnimation. fromValue = [NSValue valueWithCGRect: CGRectMake (300, 10, 0, 0)]; positionAnimation. toValue = [NSValue valueWithCGRect: CGRectMake (300, 0, 0, 0)]; // same as the key, the following animation overwrites the previous [_ imageView pop_addAnimation: positionAnimation forKey: @ "frameAnimation"]; _ isOpened = NO;}-(void) changsSize :( UITapGestureRecognizer *) tap {// change the size of imgaeview // POPSpringAnimation * springAnimation = [POPSpringAnimation animationWithPropertyNamed: kPOPLayerSize]; // CGRect rect = _ imageView. frame; // if (rect. size. width = 100) {// springAnimation. toValue = [NSValue valueWithCGSize: CGSizeMake (300,300)]; //} // else // {// springAnimation. toValue = [NSValue valueWithCGSize: CGSizeMake (100,100)]; //} // springAnimation. springBounciness = 20.0; // springAnimation. springSpeed = 20.0; // [_ imageView. layer pop_addAnimation: springAnimation forKey: @ "changsize"]; // change position POPSpringAnimation * springAnimation = [POPSpringAnimation placement: kPOPLayerPosition]; CGPoint point = _ imageView. center; if (point. y = 300) {springAnimation. toValue = [NSValue valueWithCGPoint: CGPointMake (point. x,-230)];} else {springAnimation. toValue = [NSValue valueWithCGSize: CGSizeMake (point. x, 300)];} // Elasticity Value springAnimation. springBounciness = 20.0; // elastic speed springAnimation. springSpeed = 20.0; [_ imageView pop_addAnimation: springAnimation forKey: @ "changeposition"];} // drag gesture //-(void) handlePan :( UIPanGestureRecognizer *) recognizer // {// POPSpringAnimation * anim = [POPSpringAnimation animationWithPropertyNamed: kPOPLayerPositionY]; // speed // anim. velocity = @ 2000; // rebound -- the parameter variation range that affects the animation effect // anim. springBounciness = 20; // dynamic shaking rate // anim. dynamicsMass = 5; // anim. springSpeed = 12; // [anim setCompletionBlock: ^ (POPAnimation * anim, BOOL finished) {//}]; /// [_ imageView. layer pop_addAnimation: anim forKey: @ "anim"]; // left and right swing-(void) playAction {// POPSpringAnimation * anim = [POPSpringAnimation placement: kPOPLayerPositionX]; //// speed // anim. velocity = @ 2000; // rebound -- the parameter variation range that affects the animation effect // anim. springBounciness = 20; // dynamic shaking rate // anim. dynamicsMass = 5; // anim. springSpeed = 12; // [anim setCompletionBlock: ^ (POPAnimation * anim, BOOL finished) {//}]; /// [_ btn. layer pop_addAnimation: anim forKey: @ "anim"]; //} @ end

You can also go to my gihob URL to download: https://github.com/wang820203420/popTest



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.