commit | c62f2cacaba48f8901ad811f23c2cbc9581364aa | [log] [tgz] |
---|---|---|
author | Ian Gordon <iangordon@google.com> | Mon Aug 06 21:30:52 2018 |
committer | Ian Gordon <iangordon@google.com> | Mon Aug 06 21:30:52 2018 |
tree | 3286562d4f5b63136e14136562b5eebd445a318f | |
parent | 9c343579df0e74225fef69db3218f1794aa432db [diff] | |
parent | be93fc24f64723f481ee2a2444ace0d01988db68 [diff] |
Merge branch 'release-candidate' into stable
MDFInternationalization assists in internationalizing your iOS app or components' user interface.
A UIView is positioned within its superview in terms of a frame (CGRect) consisting of an origin and a size. When a device is set to a language that is written from Right-to-Left (RTL), we often want to mirror the interface around the vertical axis. This library contains functions to assist in modifying frames and edge insets for RTL.
// To flip a subview's frame horizontally, pass in subview.frame and the width of its parent. CGRect originalFrame = childView.frame; CGRect flippedFrame = MDFRectFlippedHorizontally(originalFrame, CGRectGetWidth(self.bounds)); childView.frame = flippedFrame;
A category on UIImage backports iOS 10's [UIImage imageWithHorizontallyFlippedOrientation]
to earlier versions of iOS.
// To mirror on image, invoke mdf_imageWithHorizontallyFlippedOrientation. UIImage *mirroredImage = [originalImage mdf_imageWithHorizontallyFlippedOrientation];
A category on UIView backports iOS 9‘s -[UIView semanticContentAttribute]
and iOS 10’s -[UIView effectiveUserInterfaceLayoutDirection]
to earlier versions of iOS.
// To set a semantic content attribute, set the mdf_semanticContentAttribute property. lockedLTRView.mdf_semanticContentAttribute = UISemanticContentAttributeForceLeftToRight; // mdf_semanticContentAttribute is used to calculate the mdf_effectiveUserInterfaceLayoutDirection if (customView.mdf_effectiveUserInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) { // Update customView's layout to be in RTL mode. }
A category on NSString offers a simple API to wrap strings in Unicode markers so that LTR and RTL text can co-exist in the same string.
// To embed an RTL string in an existing LTR string we should wrap it in Unicode directionality // markers to maintain preoper rendering. // The name of a restaurant is in Arabic or Hebrew script, but the rest of string is in Latin. NSString *wrappedRestaurantName = [restaurantName mdf_stringWithStereoReset:NSLocaleLanguageDirectionRightToLeft context:NSLocaleLanguageDirectionLeftToRight]; NSString *reservationString = [NSString stringWithFormat:@"%@ : %ld", wrappedRestaurantName, attendees];
See Examples/Flags for a detailed example of how to use the functionality provided by this library.
MDFInternationalization is licensed under the Apache License Version 2.0.