zoukankan      html  css  js  c++  java
  • 自学知识(四)

    1.解决循环引用:

    __weak __typeof(self) weakSelf = self;

     

    2.设置segmentedControl:

    1     NSArray *segmentedArray = [[NSArray alloc]initWithObjects:@"国内",@"国外",nil];
    2     _segmentedControl = [[UISegmentedControl alloc]initWithItems:segmentedArray];
    3     _segmentedControl.frame = CGRectMake(0,0,180,30);
    4     _segmentedControl.tintColor = TheThemeColor;
    5     [_segmentedControl setSelectedSegmentIndex:0];
    6     [_segmentedControl addTarget:self action:@selector(segmentedControlAction:) forControlEvents:UIControlEventValueChanged];
    7     self.navigationItem.titleView = _segmentedControl;

    3.学会使用子控制器:

    1 _chinaVC = [[PickChinaCityController alloc] init];
    2     _overseasVC = [[PickOverseasController alloc] init];
    3     
    4     [self addChildViewController:_chinaVC];
    5     [self addChildViewController:_overseasVC];

    4.设置控制器的动画:

     1 #pragma mark - 取消操作
     2 - (void)cancelAction{
     3     
     4     CATransition *animation = [CATransition animation];
     5     animation.duration = 0.5;
     6     animation.timingFunction = UIViewAnimationCurveEaseInOut;
     7     animation.type = @"pageUnCurl";
     8     animation.type = kCATransitionFade;
     9     //    animation.subtype = kCATransitionFromBottom;
    10     [self.view.window.layer addAnimation:animation forKey:nil];
    11     
    12     [self dismissViewControllerAnimated:NO completion:^{
    13         
    14     }];
    15 }

    5.给导航栏去阴影:

     1 - (void)viewWillAppear:(BOOL)animated{
     2     [super viewWillAppear:animated];
     3     
     4     if (iOS7) {
     5         self.edgesForExtendedLayout = UIRectEdgeAll;
     6         self.automaticallyAdjustsScrollViewInsets = YES;
     7         self.extendedLayoutIncludesOpaqueBars = NO;
     8     }
     9     [self.navigationController.navigationBar setTranslucent:YES];
    10 
    11     //为什么要加这个呢,shadowImage 是在ios6.0以后才可用的。但是发现5.0也可以用。不过如果你不判断有没有这个方法,
    12     //而直接去调用可能会crash,所以判断下。作用:如果你设置了上面那句话,你会发现是透明了。但是会有一个阴影在,下面的方法就是去阴影
    13     if ([self.navigationController.navigationBar respondsToSelector:@selector(shadowImage)])
    14     {
    15         [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
    16     }
    17     //以上面4句是必须的,但是习惯还是加了下面这句话
    18     [self.navigationController.navigationBar setBackgroundColor:[UIColor clearColor]];
    19 
    20 }
  • 相关阅读:
    WebGL学习笔记(一)
    svn和ftp的不同应用场合
    Java 开源博客 Solo 1.8.0 发布
    【C解毒】滥用变量
    【C解毒】答非所问
    【C解毒】错题无解
    【C解毒】怎样写main()函数
    程序员约架事件中,薛非到底是因为不会用Github还是不会写Tokenizer而没有应战?
    『一些同学学不好C语言,把罪责归于「因为教材是谭浩强写的」实在是很滑稽』吗?
    挂羊头卖狗肉蓄意欺骗读者——谭浩强《C程序设计(第四版)》中所谓的“按照C99”(二)
  • 原文地址:https://www.cnblogs.com/pengsi/p/5349876.html
Copyright © 2011-2022 走看看