Simple animated effect of iOS added to Cart

Source: Internet
Author: User
Tags vars

[OBJC]View Plaincopyprint?

[OBJC]View Plaincopyprint?
  1. #pragma mark-Animated effect added to the shopping cart
  2. Huangyibiao
  3. -(void) Addanimatedwithframe: (CGRect) Frame {
  4. //This part is animated with Self.view as the reference system
  5. frame = [[UIApplication sharedapplication]. Keywindow convertrect:frame fromview:self.  Rfcell. headbtn];
  6. UIButton *move = [[UIButton alloc] initwithframe:frame];
  7. [Move Setbackgroundcolor:uicolorfromrgb (0xFFA215)];
  8. [Move settitle:self.  Rfcell. headbtncurrenttitle Forstate:uicontrolstatenormal];
  9. [Move settitlecolor:[uicolor Whitecolor] forstate:uicontrolstatenormal];
  10. Move. Contentmode = Uiviewcontentmodescaletofill;
  11. [[UIApplication sharedapplication]. Keywindow Addsubview:move];
  12. //Add Shopping cart animation effect
  13. [UIView animatewithduration:1. 2 animations:^{
  14. Move. frame = CGRectMake (320-frame. Size. Width- 20, 24, /c5>
  15. Frame. Size. width, frame. Size. height);
  16. } completion:^ (BOOL finished) {
  17. [Move Removefromsuperview];
  18. if (selfcartcategorieslabel = = nil) {
  19. self. Cartcategorieslabel = [[UILabel alloc] initwithframe:cgrectmake ((16- 8)/ 2, (  16- 8)/ 2, 8, 8)];
  20. self. Cartcategorieslabel . textcolor = [Uicolor whitecolor];
  21. self. Cartcategorieslabel . backgroundcolor = [Uicolor clearcolor];
  22. self. Cartcategorieslabel . textalignment = Nstextalignmentcenter;
  23. self. Cartcategorieslabel . Font = [Uifont systemfontofsize:9];
  24. Uiimageview *imgview = [[Uiimageview alloc] initwithframe:cgrectmake (15, 8, 16, 1  6)];
  25. Imgview. image = [UIImage imagenamed:@ "News"];
  26. [Imgview addsubview:selfcartcategorieslabel];
  27. [self. Cartbutton Addsubview:imgview];
  28. }
  29. self. Cartcategorieslabel . Text = [NSString stringwithformat:@ "%d", _cartcategories. Count];
  30. }];
  31. return;
  32. }



The frame parameter is the frame of the button, which is the frame on the original parent view

This will convert the original frame into a frame on the window.

Update shows the number of items in the cart after the animation is complete

Simple animated effect of iOS added to Cart

Related Article

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.