chore: Initial clean commit
- Removed YuMi/Library/ (138 MB, not tracked) - Removed YuMi/Resources/ (23 MB, not tracked) - Removed old version assets (566 files, not tracked) - Excluded Pods/, xcuserdata/ and other build artifacts - Clean repository optimized for company server deployment
This commit is contained in:
55
YuMi/CustomUI/MSRTL/YYLabel+MSRTL.m
Normal file
55
YuMi/CustomUI/MSRTL/YYLabel+MSRTL.m
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// MSRTL.m
|
||||
// YuMi
|
||||
//
|
||||
// Created by duoban on 2024/4/15.
|
||||
//
|
||||
|
||||
#import "YYLabel+MSRTL.h"
|
||||
#import "NSMutableAttributedString+MSRTL.h"
|
||||
BOOL isRTLString(NSString *string) {
|
||||
if ([string hasPrefix:@"\u202B"]) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
@implementation YYLabel (MSRTL)
|
||||
|
||||
+ (void)load {
|
||||
Method oldTextMethod = class_getInstanceMethod(self,@selector(setAttributedText:));
|
||||
Method newTextMethod = class_getInstanceMethod(self, @selector(msrtl_setAttributedText:));
|
||||
method_exchangeImplementations(oldTextMethod, newTextMethod); //交换成功
|
||||
}
|
||||
|
||||
-(void)msrtl_setAttributedText:(NSAttributedString *)attributedText{
|
||||
if(attributedText == nil)return;
|
||||
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc]init];
|
||||
if(self.textAlignment == NSTextAlignmentCenter){
|
||||
if (isMSRTL()) {
|
||||
[attributedString appendAttributedString:[NSMutableAttributedString createBlankAttributeToMSRTL]];
|
||||
// [attributedString appendAttributedString:[NSMutableAttributedString createBlankAttributeToMSLTR]];
|
||||
}
|
||||
[attributedString appendAttributedString:attributedText];
|
||||
[self msrtl_setAttributedText:attributedString];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (isMSRTL()) {
|
||||
[attributedString appendAttributedString:[NSMutableAttributedString createBlankAttributeToMSRTL]];
|
||||
// [attributedString appendAttributedString:[NSMutableAttributedString createBlankAttributeToMSLTR]];
|
||||
}
|
||||
|
||||
[attributedString appendAttributedString:attributedText];
|
||||
[self msrtl_setAttributedText:attributedString];
|
||||
if(isMSRTL()){
|
||||
self.textAlignment = NSTextAlignmentRight;
|
||||
}else{
|
||||
if (self.textAlignment == NSTextAlignmentNatural) {
|
||||
self.textAlignment = NSTextAlignmentLeft;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@end
|
Reference in New Issue
Block a user