Update README.md
1 file changed
tree: 50e7dacd3f698c5a0042a25524d4400cbe0248fb
  1. Examples/
  2. MDFInternationalization.xcodeproj/
  3. Sources/
  4. Tests/
  5. .gitignore
  6. .kokoro
  7. .travis.yml
  8. BUILD
  9. CHANGELOG.md
  10. CODE_OF_CONDUCT.md
  11. CODEOWNERS
  12. CONTRIBUTING.md
  13. LICENSE
  14. MDFInternationalization.podspec
  15. README.md
  16. WORKSPACE
README.md

MDFInternationalization assists in internationalizing your iOS app or components' user interface.

GitHub release License Build Status Carthage compatible

Right-to-Left calculations for CGRects and UIEdgeInsets

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;

Mirroring Images

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];

Adding semantic context

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 ([customControl mdf_effectiveUserInterfaceLayoutDirection] == UIUserInterfaceLayoutDirectionRightToLeft) {
  // Update customControl's layout to be in RTL mode.
}

Usage

See Examples/Flags for a detailed example of how to use the functionality provided by this library.

License

MDFInternationalization is licensed under the Apache License Version 2.0.