iOS开发日常遇到的小技巧归纳

一、开启子线程、回到主线程:

    // 异步子线程操作
    dispatch_queue_t  globalQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_async(globalQueue, ^{
        NSLog(@"子线程");
        /*
         * add code on child thread
         */

        // 返回主线程
        dispatch_async(dispatch_get_main_queue(), ^(void){
            NSLog(@"主线程");
            /*
             * add code on main thread
             */
        });
    });

二、label等控件在设置动态改变的字体时。如:下载从0.00%变化到100.00%时,因为有些字体会动态改变字体间的行间距,所有看起来很不好看。需要将字体换为:Helvetica Neue字体,不会改变字体间的间距。

猜你喜欢

转载自www.cnblogs.com/liuhuakun/p/11198752.html