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