<legend id='1ytiwzgm'><style id='conwk4z7'><dir id='zzwbvh4v'><q id='euqfa0f4'></q></dir></style></legend>

  • <tfoot id='lsz1prwd'></tfoot>

        <tbody id='epb9e1n6'></tbody>
        <i id='8vn2pv2v'><tr id='dpcltazh'><dt id='oy5lzezs'><q id='9lcpnge9'><span id='sv78vsp5'><b id='zsdag6ze'><form id='wcaa3sa8'><ins id='g2odnqv2'></ins><ul id='gcxn1jpr'></ul><sub id='z5hct6hw'></sub></form><legend id='w2agugn9'></legend><bdo id='icswbcfl'><pre id='fdl98k8q'><center id='2s88ak1i'></center></pre></bdo></b><th id='0uxxbohu'></th></span></q></dt></tr></i><div id='t7rke6m4'><tfoot id='jokmlamz'></tfoot><dl id='exo1tsz3'><fieldset id='3maf2m2h'></fieldset></dl></div>

        <small id='xhpqlary'></small><noframes id='6cdby3d1'>

        网站建设公司当前位置 : 网站建设公司 > 知识普及

        APP开发小知识点

        发布时间:2021-12-07 15:48   浏览次数:次   
        1.获得项目中info.plist文件的内容
        1> [NSBundle mainBundle].infoDictionary
        2> 版本号在info.plist中的key:kCFBundleVersionKey
         
        2.自定义控制器的view
        重写loadView方法(不需要调用[super loadView])
         
        3.控制器view的高度和状态栏的关系
        创建控制器的view时,系统会检测状态栏是否显示
        * 如果有状态栏,那么控制器view的高度是460(iPhone5中是548)
        * 如果没有状态栏,那么控制器view的高度是480(iPhone5中是568)
         
        4.[UIScreen mainScreen].applicationFrame的取值
        以3.5inch为例(320x480)
        1> 没有状态栏,applicationFrame的值{{0, 0}, {320, 480}}
        2> 有状态栏,applicationFrame的值{{0, 20}, {320, 460}}
         
        5.按钮的状态
        UIControlStateNormal       普通(默认的状态)
        UIControlStateHighlighted  高亮(用户长按的时候)
        UIControlStateDisabled     失效(通过代码控制:enabled属性)
        UIControlStateSelected     选中(通过代码控制:selected属性)
         
        6.错误调试技巧
        1> 一个控件无法显示出来的可能原因
        * 没有宽高(宽高为0)
        * 位置不对
        * hidden=YES
        * 没有被addSubview到屏幕上
         
        2> 一个UIScrollView无法滚动
        * contentSize没有值
        * 不能接收到触摸事件
         
        3> 一个控件无法跟用户交互(无法接收事件)的可能原因
        * (父控件的)userInteractionEnabled = NO;
        * (父控件的)hidden = YES
        * (父控件的)alpha <= 0.01
        * (父控件的)背景是clearColor
         
        7.按钮的设置
        // 高亮状态下不更改图片的颜色
        self.adjustsImageWhenHighlighted = NO;
        // 是否选中状态
        self.selected = YES;
        // 是否可用状态
        self.enabled = YES;
         
        一、按钮的设置
        0.设置背景图片
        [btn setBackgroundImage:image forState:UIControlStateNormal];
         
        1.设置内部UIImageView的图片
        [btn setImage:image forState:UIControlStateNormal];
        // 不能写成btn.imageView.image = image;
         
        2.设置内部UILabel的文字
        [btn setTitle:@"43" forState:UIControlStateNormal];
        // 不能写成btn.titleLabel.text = @"43";
         
        3.调整内部ImageView的frame
        - (CGRect)imageRectForContentRect:(CGRect)contentRect
         
        4.调整内部UILabel的frame
        - (CGRect)titleRectForContentRect:(CGRect)contentRect
         
        5.覆盖父类在highlighted时的所有操作
        - (void)setHighlighted:(BOOL)highlighted { }
         
        6.文字居中
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
         
        7.文字大小
        self.titleLabel.font = [UIFont systemFontOfSize:12];
         
        8.图片的内容模式
        self.imageView.contentMode = UIViewContentModeCenter;
         
        二、添加子控制器
        - (void)addChildViewController:
        * 会将子控制器添加到childViewControllers,并且子控制器是有顺序的
        * 目的就是持有子控制器,不让子控制器销毁,保证主控制器在,子控制器就在
         
        三、让一个控制器拥有导航栏的最快方法:包装一层导航控制器
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:controller];
         
        四、UIBarButtonItem
        1> 创建一个带有文字的item
        [[UIBarButtonItem alloc] initWithTitle:@"设置" style:UIBarButtonItemStyleBordered target:nil action:nil]
         
        2> 创建一个包装了自定义View的item
        - (id)initWithCustomView:(UIView *)customView
         
        五、设置导航栏UINavigationBar主题
        // 1.appearance方法返回一个导航栏的外观对象
        // 修改了这个外观对象,相当于修改了整个项目中的外观
        UINavigationBar *bar = [UINavigationBar appearance];
         
        // 2.设置导航栏的背景图片
        [bar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
         
        // 3.设置导航栏文字的主题
        [bar setTitleTextAttributes:@{
          UITextAttributeTextColor : [UIColor blackColor],
          UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetZero]
         }];
         
        六、设置导航按钮UIBarButtonItem主题
        // 1.修改所有UIBarButtonItem的外观
        UIBarButtonItem *barItem = [UIBarButtonItem appearance];
        // 2.修改item的背景图片
        [barItem setBackgroundImage:image1 forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
        [barItem setBackgroundImage:image2 forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
        // 3.修改item上面的文字样式
        NSDictionary *dict = @{
            UITextAttributeTextColor : [UIColor darkGrayColor],
            UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetZero]
        };
        [barItem setTitleTextAttributes:dict forState:UIControlStateNormal];
        [barItem setTitleTextAttributes:dict forState:UIControlStateHighlighted];
         
        七、设置状态栏样式
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
         

          <tbody id='bzd1uyc9'></tbody>

        <legend id='zxf2ozfc'><style id='7pgvp9g9'><dir id='zlx852ll'><q id='203as0tr'></q></dir></style></legend>

        <i id='fmrwdz19'><tr id='q2onu0ul'><dt id='tnql6q5r'><q id='5ywx2i3j'><span id='dj97bjpi'><b id='tgbjm6r3'><form id='bkn3mq17'><ins id='nfezec50'></ins><ul id='p5wc9p5d'></ul><sub id='x9w629x0'></sub></form><legend id='6ez1wswq'></legend><bdo id='gma824od'><pre id='asdtklla'><center id='9ykiupln'></center></pre></bdo></b><th id='vsoqe8s7'></th></span></q></dt></tr></i><div id='svvqiwe1'><tfoot id='d2lhcy4t'></tfoot><dl id='uwgqw57o'><fieldset id='zryifan1'></fieldset></dl></div>
        • <small id='g3l1r30n'></small><noframes id='ocs0fs8s'>

          • <tfoot id='fxzh6w9e'></tfoot>

              本文来源于网络,若有侵权请联系3449817223#qq.com,将在第一时间删除。

              上一篇:外包公司常见的坑 小程序开发上一篇
              <tfoot id='7yijv6a0'></tfoot>

                    <tbody id='fyw057dp'></tbody>
                1. <small id='v5agnysp'></small><noframes id='8jvqygdl'>

                  <i id='r8kev4mv'><tr id='fmirorgt'><dt id='fd1z3en5'><q id='twzd0hbu'><span id='1an771zc'><b id='8oi1r7ak'><form id='oupekk37'><ins id='bm9xjlf3'></ins><ul id='omj5hk0j'></ul><sub id='gicgxqnv'></sub></form><legend id='swgd1x8i'></legend><bdo id='289oy30t'><pre id='sxnz3cit'><center id='o6pc1mtd'></center></pre></bdo></b><th id='4s08o4bs'></th></span></q></dt></tr></i><div id='my7e2wtl'><tfoot id='mka7jims'></tfoot><dl id='tgheriff'><fieldset id='r5tos6x1'></fieldset></dl></div>
                  <legend id='itmr2vzo'><style id='w4qm7rsm'><dir id='30iqq8w4'><q id='r8atnuti'></q></dir></style></legend>