• ios simple code snap


    #define SWITCH_TAG 102

    - (void) updateSwitch:(id)sender 
    {
        // toggle the switch from its current setting
        UISwitch *s = [self.view.window switchWithTag:SWITCH_TAG];
        [s setOn:!s.isOn];
    }

     - (void) updateTime:(id)sender 

    {
        // set the label to the current time
        [self.view.window labelWithTag:LABEL_TAG].text = [[NSDate date] description];
    }
    // This is a private version of the function that appears in my UIView Frame category
    // It's included here as a private function to avoid requiring the other file
    CGRect rectWithCenter(CGRect rect, CGPoint center)
    {
        CGRect newrect = CGRectZero;
        newrect.origin.x = center.x-CGRectGetMidX(rect);
        newrect.origin.y = center.y-CGRectGetMidY(rect);
        newrect.size = rect.size;
        return newrect;

     xcode debug instruction:print po  bt 

    change to GDB debugger:Product”->“Manage Schemes”->Info->Debugger->select GDB 

    relevant  information

    http://blog.163.com/agw_slsyn/blog/static/30915112201213112813356/ 

    http://www.cnblogs.com/lovecode/articles/2343818.html 

    - (void) move: (NSTimer *) aTimer
    {
        // Rotate each iteration by 1% of PI
        CGFloat angle = theta * (M_PI / 100.0f);
        CGAffineTransform transform = CGAffineTransformMakeRotation(angle);
        
        // Theta ranges between 0% and 199% of PI, i.e. between 0 and 2*PI
        theta = (theta + 1) % 200;

        // For fun, scale by the absolute value of the cosine
        float degree = cos(angle);
        if (degree < 0.0) degree *= -1.0f;
        degree += 0.5f;
        
        // Create add scaling to the rotation transform
        CGAffineTransform scaled = CGAffineTransformScale(transform, degree, degree);
        
        // Apply the affine transform
        [[self.view viewWithTag:999] setTransform:scaled];

    }

     - (void) fadeOut: (id) sender

    {
        CGContextRef context = UIGraphicsGetCurrentContext();
        [UIView beginAnimations:nil context:context];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        [UIView setAnimationDuration:1.0];
        [[self.view viewWithTag:999] setAlpha:0.0f];
        [UIView commitAnimations];
        self.navigationItem.rightBarButtonItem = BARBUTTON(@"Fade In", @selector(fadeIn:));
    }

    - (void) fadeIn: (id) sender
    {
        CGContextRef context = UIGraphicsGetCurrentContext();
        [UIView beginAnimations:nil context:context];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        [UIView setAnimationDuration:1.0];
        [[self.view viewWithTag:999] setAlpha:1.0f];
        [UIView commitAnimations];
        self.navigationItem.rightBarButtonItem = BARBUTTON(@"Fade Out", @selector(fadeOut:));
    }

     - (void) swap: (id) sender

    {
        // hide the button
        self.navigationItem.rightBarButtonItem = nil;
        
        UIView *frontObject = [[self.view subviews] objectAtIndex:2];
        UIView *backObject = [[self.view subviews] objectAtIndex:1];
        
        CGContextRef context = UIGraphicsGetCurrentContext();
        [UIView beginAnimations:nil context:context];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        [UIView setAnimationDuration:1.0];
        
        frontObject.alpha = 0.0f;
        backObject.alpha = 1.0f;
        frontObject.transform = CGAffineTransformMakeScale(0.25f0.25f);
        backObject.transform = CGAffineTransformIdentity;
        [self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:2];

        [UIView setAnimationDelegate:self];
        [UIView setAnimationDidStopSelector:@selector(animationFinished:)];
        [UIView commitAnimations];
        
    }

     - (void) flip: (id) sender

    {
        // hide the button
        self.navigationItem.rightBarButtonItem = nil;
        
        CGContextRef context = UIGraphicsGetCurrentContext();
        [UIView beginAnimations:nil context:context];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        [UIView setAnimationDuration:1.0];
        
        UIView *whiteBackdrop = [self.view viewWithTag:100];

        // Choose left or right flip
        if ([(UISegmentedControl *)self.navigationItem.titleView selectedSegmentIndex])
            [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:whiteBackdrop cache:YES];
        else
            [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:whiteBackdrop cache:YES];

        NSInteger purple = [[whiteBackdrop subviews] indexOfObject:[whiteBackdrop viewWithTag:999]];
        NSInteger maroon = [[whiteBackdrop subviews] indexOfObject:[whiteBackdrop viewWithTag:998]];
        [whiteBackdrop exchangeSubviewAtIndex:purple withSubviewAtIndex:maroon];

        [UIView setAnimationDelegate:self];
        [UIView setAnimationDidStopSelector:@selector(animationFinished:)];
        [UIView commitAnimations];
    }
  • 相关阅读:
    MyBatis整合Spring编码
    Intellij IDEA中如何给main方法赋args
    InputStream类的available()方法
    使用IDEA在引入Schema空间时报错URI is not registered解决方法以及Idea @Autowired取消提示 方法
    HelloServlet类继承HttpServlet利用HttpServletResponse对象
    DAO层单元测试编码和问题排查
    安卓Activity布局简述
    新建工程spring boot
    MySQL无法启动
    CoffeeScript编写简单新闻页(仅UI)
  • 原文地址:https://www.cnblogs.com/zyip/p/2653013.html
Copyright © 2020-2023  润新知