mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			43 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Matlab
		
	
		
		
			
		
	
	
			43 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Matlab
		
	
| 
								 
											8 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 | 
							
								//  Copyright (c) 2017 Open Whisper Systems. All rights reserved.
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#import "NSAttributedString+OWS.h"
							 | 
						||
| 
								 | 
							
								#import "UIView+OWS.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								NS_ASSUME_NONNULL_BEGIN
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@implementation NSAttributedString (OWS)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								- (NSAttributedString *)rtlSafeAppend:(NSString *)text
							 | 
						||
| 
								 | 
							
								                           attributes:(NSDictionary *)attributes
							 | 
						||
| 
								 | 
							
								                        referenceView:(UIView *)referenceView
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    OWSAssert(text);
							 | 
						||
| 
								 | 
							
								    OWSAssert(attributes);
							 | 
						||
| 
								 | 
							
								    OWSAssert(referenceView);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    NSAttributedString *substring = [[NSAttributedString alloc] initWithString:text attributes:attributes];
							 | 
						||
| 
								 | 
							
								    return [self rtlSafeAppend:substring referenceView:referenceView];
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								- (NSAttributedString *)rtlSafeAppend:(NSAttributedString *)string referenceView:(UIView *)referenceView
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    OWSAssert(string);
							 | 
						||
| 
								 | 
							
								    OWSAssert(referenceView);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    NSMutableAttributedString *result = [NSMutableAttributedString new];
							 | 
						||
| 
								 | 
							
								    if ([referenceView isRTL]) {
							 | 
						||
| 
								 | 
							
								        [result appendAttributedString:string];
							 | 
						||
| 
								 | 
							
								        [result appendAttributedString:self];
							 | 
						||
| 
								 | 
							
								    } else {
							 | 
						||
| 
								 | 
							
								        [result appendAttributedString:self];
							 | 
						||
| 
								 | 
							
								        [result appendAttributedString:string];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    return [result copy];
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								NS_ASSUME_NONNULL_END
							 |