• 大小: 25KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-11
  • 语言: 其他
  • 标签: ios扩展  

资源简介

全局转换简繁体,只要把这个资源代码放到工程目录里,即可。自动将全部界面的简体中文转换成繁体中文。

资源截图

代码片段和文件信息

//
//  UIButton+FontExtension.m
//  frameWork
//
//  Created by 王宁 on 2018/8/1.
//  Copyright © 2018年 gnnt. All rights reserved.
//

#import “UIButton+FontExtension.h“
#import “ZMChineseConvert.h“
#import 
@implementation UIButton (FontExtension)
+(void)load{
    
    //只执行一次这个方法
    
    static dispatch_once_t onceToken;
    
    dispatch_once(&onceToken ^{
        
        Class class = [self class];
        
        // When swizzling a class method use the following:
        
        // Class class = object_getClass((id)self);
        
        //替换三个方法
        
        SEL originalSelector = @selector(init);
        
        SEL originalSelector2 = @selector(initWithframe:);
        
        SEL originalSelector3 = @selector(awakeFromNib);
        
        SEL swizzledSelector = @selector(QMbaseInit);
        
        SEL swizzledSelector2 = @selector(QMbaseInitWithframe:);
        
        SEL swizzledSelector3 = @selector(QMbaseAwakeFromNib);
        
        Method originalMethod = class_getInstanceMethod(class originalSelector);
        
        Method originalMethod2 = class_getInstanceMethod(class originalSelector2);
        
        Method originalMethod3 = class_getInstanceMethod(class originalSelector3);
        
        Method swizzledMethod = class_getInstanceMethod(class swizzledSelector);
        
        Method swizzledMethod2 = class_getInstanceMethod(class swizzledSelector2);
        
        Method swizzledMethod3 = class_getInstanceMethod(class swizzledSelector3);
        
        BOOL didAddMethod =
        
        class_addMethod(class
                        
                        originalSelector
                        
                        method_getImplementation(swizzledMethod)
                        
                        method_getTypeEncoding(swizzledMethod));
        
        BOOL didAddMethod2 =
        
        class_addMethod(class
                        
                        originalSelector2
                        
                        method_getImplementation(swizzledMethod2)
                        
                        method_getTypeEncoding(swizzledMethod2));
        
        BOOL didAddMethod3 =
        
        class_addMethod(class
                        
                        originalSelector3
                        
                        method_getImplementation(swizzledMethod3)
                        
                        method_getTypeEncoding(swizzledMethod3));
        
        if (didAddMethod) {
            
            class_replaceMethod(class
                                
                                swizzledSelector
                                
                                method_getImplementation(originalMethod)
                                
                                method_getTypeEncoding(originalMethod));
            
        } else {
            
            method_exchangeImplementations(originalMeth

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-08-08 17:03  ChineseConvert\
     文件        4607  2018-08-08 16:07  ChineseConvert\ZMChineseConvert.m
     目录           0  2018-08-09 13:37  __MACOSX\
     目录           0  2018-08-09 13:37  __MACOSX\ChineseConvert\
     文件         181  2018-08-08 16:07  __MACOSX\ChineseConvert\._ZMChineseConvert.m
     文件        7084  2018-08-08 16:07  ChineseConvert\SimplifiedCode.txt
     文件         181  2018-08-08 16:07  __MACOSX\ChineseConvert\._SimplifiedCode.txt
     文件        1632  2018-08-08 16:28  ChineseConvert\UITabBarItem+FontExtension.m
     文件         333  2018-08-08 16:28  __MACOSX\ChineseConvert\._UITabBarItem+FontExtension.m
     文件         210  2018-08-08 16:07  ChineseConvert\UITextView+FontExtension.h
     文件         237  2018-08-08 16:07  __MACOSX\ChineseConvert\._UITextView+FontExtension.h
     文件        7430  2018-08-08 16:31  ChineseConvert\UIButton+FontExtension.m
     文件         176  2018-08-08 16:31  __MACOSX\ChineseConvert\._UIButton+FontExtension.m
     文件        6252  2018-08-08 16:34  ChineseConvert\UILabel+FontExtension.m
     文件         176  2018-08-08 16:34  __MACOSX\ChineseConvert\._UILabel+FontExtension.m
     文件         213  2018-08-08 16:07  ChineseConvert\UITextField+FontExtension.h
     文件         237  2018-08-08 16:07  __MACOSX\ChineseConvert\._UITextField+FontExtension.h
     文件         214  2018-08-08 16:07  ChineseConvert\UITabBarItem+FontExtension.h
     文件         237  2018-08-08 16:07  __MACOSX\ChineseConvert\._UITabBarItem+FontExtension.h
     文件         598  2018-08-08 16:07  ChineseConvert\ZMChineseConvert.h
     文件         181  2018-08-08 16:07  __MACOSX\ChineseConvert\._ZMChineseConvert.h
     文件         202  2018-08-08 16:07  ChineseConvert\UILabel+FontExtension.h
     文件         181  2018-08-08 16:07  __MACOSX\ChineseConvert\._UILabel+FontExtension.h
     文件         207  2018-08-08 16:07  ChineseConvert\UIButton+FontExtension.h
     文件         181  2018-08-08 16:07  __MACOSX\ChineseConvert\._UIButton+FontExtension.h
     文件        1284  2018-08-08 16:07  ChineseConvert\UITextView+FontExtension.m
     文件         237  2018-08-08 16:07  __MACOSX\ChineseConvert\._UITextView+FontExtension.m
     文件        7084  2018-08-08 16:07  ChineseConvert\TraditionalCode.txt
     文件         181  2018-08-08 16:07  __MACOSX\ChineseConvert\._TraditionalCode.txt
     文件        2240  2018-08-08 17:03  ChineseConvert\UITextField+FontExtension.m
     文件         333  2018-08-08 17:03  __MACOSX\ChineseConvert\._UITextField+FontExtension.m
............此处省略1个文件信息

评论

共有 条评论

相关资源