1. statusBar 移动位置

    NSString *key = [[NSString alloc] initWithData:[NSData dataWithBytes:(unsigned char []){0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x61, 0x72} length:] encoding:NSASCIIStringEncoding];
      key = @"statusBar";//一样的效果
    id object = [UIApplication sharedApplication];
    UIView *statusBar;
    if ([object respondsToSelector:NSSelectorFromString(key)]) {
    statusBar = [object valueForKey:key];
    }
    statusBar.transform = CGAffineTransformMakeTranslation(self.paneView.frame.origin.x, self.paneView.frame.origin.y);
  2. tabBar 自定义的图标
    if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
    UIImage *icon = [[UIImage imageNamed:@"jinghua-selected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage *unIcon = [[UIImage imageNamed:@"jinghua"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [nc.tabBarItem setFinishedSelectedImage:icon withFinishedUnselectedImage:unIcon];
    } else {
    [nc.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"jinghua-selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"jinghua"]];
    }
    [nc.tabBarItem setTitle:NSLocalizedString(@"精华", nil)];
  3. tabBarItem 自定义颜色
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
    [UIColor colorWithWhite:./ alpha:], UITextAttributeTextColor, nil]
    forState:UIControlStateNormal]; //Item选中状态颜色
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
    [UIColor colorWithWhite:./ alpha:], UITextAttributeTextColor, nil]
    forState:UIControlStateSelected];
  4. 扩展点击区域
    #import <objc/runtime.h>
    @implementation UIControl (userInteractoinEdgeInsets)
    static char topNameKey;
    static char rightNameKey;
    static char bottomNameKey;
    static char leftNameKey; -(void)setUserInteractionEdgeInsets:(UIEdgeInsets)edgeInsets{
    objc_setAssociatedObject(self, &topNameKey, [NSNumber numberWithFloat:edgeInsets.top], OBJC_ASSOCIATION_COPY_NONATOMIC);
    objc_setAssociatedObject(self, &rightNameKey, [NSNumber numberWithFloat:edgeInsets.right], OBJC_ASSOCIATION_COPY_NONATOMIC);
    objc_setAssociatedObject(self, &bottomNameKey, [NSNumber numberWithFloat:edgeInsets.bottom], OBJC_ASSOCIATION_COPY_NONATOMIC);
    objc_setAssociatedObject(self, &leftNameKey, [NSNumber numberWithFloat:edgeInsets.left], OBJC_ASSOCIATION_COPY_NONATOMIC);
    } - (CGRect)enlargedRect
    {
    NSNumber* topEdge = objc_getAssociatedObject(self, &topNameKey);
    NSNumber* rightEdge = objc_getAssociatedObject(self, &rightNameKey);
    NSNumber* bottomEdge = objc_getAssociatedObject(self, &bottomNameKey);
    NSNumber* leftEdge = objc_getAssociatedObject(self, &leftNameKey);
    if (topEdge && rightEdge && bottomEdge && leftEdge)
    {
    return CGRectMake(self.bounds.origin.x - leftEdge.floatValue,
    self.bounds.origin.y - topEdge.floatValue,
    self.bounds.size.width + leftEdge.floatValue + rightEdge.floatValue,
    self.bounds.size.height + topEdge.floatValue + bottomEdge.floatValue);
    }
    else
    {
    return self.bounds;
    }
    } - (UIView*)hitTest:(CGPoint) point withEvent:(UIEvent*) event
    {
    CGRect rect = [self enlargedRect];
    if (CGRectEqualToRect(rect, self.bounds))
    {
    return [super hitTest:point withEvent:event];
    }
    return CGRectContainsPoint(rect, point) ? self : nil;
    } @end
  5. tabBarController 动态添加删除
    @implementation UITabBarController (dynamic)
    -(void)deleteChildViewController:(UIViewController*)controller{
    if ([self.viewControllers containsObject:controller]){
    NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:self.viewControllers];
    [viewControllers removeObject:controller];
    self.viewControllers = [NSArray arrayWithArray:viewControllers];
    }
    } -(void)insertChildViewController:(UIViewController*)controller atIndex:(NSInteger)index{
    if (index >= && index <=self.viewControllers.count && ![self.viewControllers containsObject:controller]) {
    NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:self.viewControllers];
    if (!viewControllers) {
    viewControllers = [NSMutableArray array];
    }
    [viewControllers insertObject:controller atIndex:index];
    self.viewControllers = [NSArray arrayWithArray:viewControllers];
    }
    }
    @end
  6. navigationBar 自定义
    [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], UITextAttributeTextColor, nil]];
    
        if ([[UIDevice currentDevice].systemVersion floatValue]<7.0) {
    [self.navigationBar setTintColor:[UIColor colorWithRed:0.0 green:./ blue:./ alpha:]];
    }else{
    [self.navigationBar setBarTintColor:[UIColor colorWithRed:0.0 green:./ blue:./ alpha:]];
    }
  7. 本地语言修改
    [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:language, nil]
    forKey:@"AppleLanguages"]; [[NSUserDefaults standardUserDefaults] synchronize];
  8. UITableView控制表格线

    -(void)viewDidLayoutSubviews
    {
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
    [self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
    } if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
    [self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
    }
    } -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
    {
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
    [cell setSeparatorInset:UIEdgeInsetsZero];
    } if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
    [cell setLayoutMargins:UIEdgeInsetsZero];
    }
    }
  9. UItableView 中或是其superview 中有 tap 事件时 tableView 不响应 tableVeiw:didSelectedRowAtIndex: 方法
  10.  

ios UI实现技巧的更多相关文章

  1. iOS:小技巧(不断更新)

    记录下一些不常用技巧,以防忘记,复制用. 1.获取当前的View在Window的frame: UIWindow * window=[[[UIApplication sharedApplication] ...

  2. iOS:小技巧(19-02-12更)

    记录下一些不常用技巧,以防忘记,复制用. 1.UIImageView 和UILabel 等一些控件,需要加这句才能成功setCorn _myLabel.layer.masksToBounds = YE ...

  3. iOS 页面流畅技巧(1)

    一.屏幕显示图像原理 首先明确两个概念:水平同步信号.垂直同步信号. CRT 的电子枪按照上图中的方式,从上到下一行一行的扫描,扫描完成后显示器就呈现一帧画面,随后电子枪回到初始位置继续下一次的扫描. ...

  4. [IOS]IOS UI指南

    [IOS]IOS UI指南 众所周知,IOS的界面设计,越来越流行,可以说都形成了一个标准,搜集了一些资料,供自己以后学习使用! iOS Human Interface Guidelines (中文翻 ...

  5. iOS开发实用技巧—Objective-C中的各种遍历(迭代)方式

    iOS开发实用技巧—Objective-C中的各种遍历(迭代)方式 说明: 1)该文简短介绍在iOS开发中遍历字典.数组和集合的几种常见方式. 2)该文对应的代码可以在下面的地址获得:https:// ...

  6. iOS开发实用技巧—在手机浏览器头部弹出app应用下载提示

    iOS开发实用技巧—在手机浏览器头部弹出app应用下载提示 本文介绍其简单使用: 第一步:在本地建立一个访问的服务端.  打开本地终端,在本地新建一个文件夹,在该文件夹中存放测试的html页面.   ...

  7. iOS开发实用技巧—项目新特性页面的处理

    iOS开发实用技巧篇—项目新特性页面的处理 说明:本文主要说明在项目开发中会涉及到的最最简单的新特性界面(实用UIScrollView展示多张图片的轮播)的处理. 代码示例: 新建一个专门的处理新特性 ...

  8. IOS UI 第八篇:基本UI

    实现图片的滚动,并且自动停止在每张图片上     - (void)viewDidLoad{    [super viewDidLoad]; UIScrollView *scrollView = [[U ...

  9. iOS开发小技巧 - UILabel添加中划线

    iOS开发小技巧 遇到的问题: 给Label添加中划线,然后并没有效果 NSString *str = [NSString stringWithFormat:@"合计金额 ¥%.2f&quo ...

随机推荐

  1. 二、MongoDB的基础知识简介

    1.文档.集合和数据库 a).文档:因为MongoDB是面向文档的数据库,那么可想而知文档是它的基本单元,相当于关系型数据库中的行! Ⅰ.它是由键值对组成的一个有序集:注:键不能为空且是字符串类型的. ...

  2. yii2解析非x-www-form-urlencoded类型的请求数据(json,xml)

    组件配置添加: 'request' => [ 'parsers' => [ 'application/json' => 'yii\web\JsonParser', 'applicat ...

  3. ContentProvider与ContentResolver使用【转】

    这篇文章被转载而转载者未注明原文出处,在此未加上原文地址链接,本人向原作者致以歉意. 下面是文章内容: 使用ContentProvider共享数据: 当应用继承ContentProvider类,并重写 ...

  4. 【easyui】--combobox--赋值和获取选中的值

    //初始化下拉选框 $('#communityIdDiv').combobox({ url:basepath+"pushController/queryCommonityName" ...

  5. Eclipse编码问题

    通常在Eclipse下,mac和windows编码是不一样的.如果含有中文java sources通常会出现乱码. 解决---小程序! import java.io.File; import java ...

  6. DevExpress控件开发常用要点(项目总结版)

    使用DevExpress控件来做项目开发已经有很长一段时间了,在摸索开发到客户苛刻要求的过程中,其中碰到过很多问题需要解决的,随着一个个问题的解决,也留下很多对DevExpress控件的使用经验及教训 ...

  7. 第二章 管理程序流(In .net4.5) 之 管理多线程

    1. 概述 本章包括同步资源以及取消长时间任务相关的内容. 2. 主要内容 2.1 同步资源 ① lock关键字实现.会阻塞程序,有可能会导致死锁. ② volatile关键字可以禁用编译优化,用于避 ...

  8. jquery.unobtrusive-ajax.js的扩展,做到片段式加载

    //ajax支持库 /*! ** Unobtrusive Ajax support library for jQuery ** Copyright (C) Microsoft Corporation. ...

  9. html5 shiv

    使用html5标签吧!ie6.ie7.ie8不支持怎么办?它的原理是如此的简单:    1.document.createElement("ele");  // js虚拟创建一个元 ...

  10. 先登陆面试再者Tabs标签导航,多次网络请求共享cookie,本地存储cookie

    1,index.ng.html: <head> <title>ionic todo example</title> </head> <body n ...