自学知识(三)

1.设置状态栏的样式:

1 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
2     // Override point for customization after application launch.
3      [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
4     return YES;
5 }

 

2.数组的遍历:

- (NSEnumerator *)objectEnumerator;从前向后

- (NSEnumerator *)reverseObjectEnumerator;从后向前

        NSArray* reversedArray = [[_myArray reverseObjectEnumerator] allObjects];

 

3. 设置导航栏的标题样式:

1  NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:40],NSForegroundColorAttributeName:[UIColor redColor]};
2     
3 //    self.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor blackColor] forKey:NSForegroundColorAttributeName];
4     self.navigationBar.titleTextAttributes = dic;
5     

 

4.复写pushViewController方法,隐藏标签栏:

1 #pragma mark 隐藏tabbar
2 -(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
3 {
4     
5     if (self.viewControllers.count > 0) {
6         viewController.hidesBottomBarWhenPushed = YES;
7     }
8     [super pushViewController:viewController animated:YES];
9 }

5.

IOS7之后   self.edgesForExtendedLayout=UIRectEdgeNone;

self.automaticallyAdjustsScrollViewInsets=NO;

只要设置了 self.edgesForExtendedLayout ,UIRectEdgeAll的时候会让tableView从导航栏下移44px,设置为UIRectEdgeNone的时候,刚刚在导航栏下面。

self.edgesForExtendedLayout=UIRectEdgeNone or UIRectEdgeAll;
self.automaticallyAdjustsScrollViewInsets=YES;

有的时候只要automaticallyAdjustsScrollViewInsets设置了YES,不管其他任何值tableView都会在导航栏下面, 
手动改self.tableView.contentInset=UIEdgeInsetsMake(64, 0, 0, 0);也不影响tableView在导航栏下面。

 

6.设置选中TabBarItem的样式和正常状态样式:

1 [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor grayColor], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
2     
3 [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
4     

 

7.不设置渲染,会是系统默认的蓝色效果:

 

1 if (iOS7) {
2         childController.tabBarItem.image = [normal imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
3         childController.tabBarItem.selectedImage = [selected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
4     }else{
5         childController.tabBarItem.selectedImage = selected;
6     }
7     

设置UIImage的渲染模式:UIImage.renderingMode

着色(Tint Color)是iOS7界面中的一个.设置UIImage的渲染模式:UIImage.renderingMode重大改变,你可以设置一个UIImage在渲染时是否使用当前视图的Tint Color。UIImage新增了一个只读属性:renderingMode,对应的还有一个新增方法:imageWithRenderingMode:,它使用UIImageRenderingMode枚举值来设置图片的renderingMode属性。该枚举中包含下列值:

  1. UIImageRenderingModeAutomatic  // 根据图片的使用环境和所处的绘图上下文自动调整渲染模式。  
  2. UIImageRenderingModeAlwaysOriginal   // 始终绘制图片原始状态,不使用Tint Color。  
  3. UIImageRenderingModeAlwaysTemplate   // 始终根据Tint Color绘制图片,忽略图片的颜色信息。  

 

8.

//不设置此处会导致View上移

    if(iOS7) {

        self.edgesForExtendedLayout = UIRectEdgeNone;

        self.extendedLayoutIncludesOpaqueBars = NO;

        self.modalPresentationCapturesStatusBarAppearance = NO;

    }

 

9.网络请求注意点:

 1 + (void)getWithURL:(NSString *)url params:(NSDictionary *)params success:(HttpSuccess)success failure:(HttpFailure)failure{
 2     //1.使用 NSURLConnection版本的AFNetworking
 3     //1.1创建一个AFN管理对象
 4     AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
 5     //1.2告诉manager只下载原始数据, 不要解析数据(一定要写)
 6     //AFN即可以下载网络数据, 又可以解析json数据,如果不写下面的  自动就解析json
 7     //由于做服务器的人返回json数据往往不规范, 凡是AFN又检查很严格,导致json解析往往失败
 8     //下面这句话的意思是 告诉AFN千万别解析, 只需要给我裸数据就可以
 9     manager.responseSerializer = [AFHTTPResponseSerializer serializer];
10     [manager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
11         NSData *data = operation.responseData;
12         NSDictionary *dict = [NSJSONSerialization  JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
13         if (success) {
14             success(dict);
15         }
16     }failure:^(AFHTTPRequestOperation *operation, NSError *error) {
17         if (failure) {
18             failure(error);
19         }
20     }];
21 }

 

posted on 2016-04-02 20:47  玉思盈蝶  阅读(159)  评论(0编辑  收藏  举报

导航