├── .gitignore
├── LICENSE
├── README.md
├── RTLButton.h
├── RTLButton.m
├── RTLButton.podspec
└── screenshot.png
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 |
20 | # CocoaPods
21 | #
22 | # We recommend against adding the Pods directory to your .gitignore. However
23 | # you should judge for yourself, the pros and cons are mentioned at:
24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25 | #
26 | #Pods/
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Anton Bukov
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RTLButton
2 | UIButton subclass with image and title aligned Right To Left
3 |
4 | You will be able to see RTLButton right in Xcode IB:
5 |
6 |
7 |
8 | ## Usage
9 |
10 | Right now CocoaPods solution not works properly because of Xcode bug:
11 |
12 | ```
13 | pod 'RTLButton'
14 | ```
15 |
16 | So just copy source code to your project or add git submodule:
17 |
18 | ```
19 | git submodule add https://github.com/k06a/RTLButton RTLButton
20 | ```
21 |
22 | ## Contribute
23 |
24 | Please develop `TTBButton` (Top To Bottom) class and `BTTButton` (Bottom To Top) subclass with inverse logic :)
25 |
--------------------------------------------------------------------------------
/RTLButton.h:
--------------------------------------------------------------------------------
1 | //
2 | // RTLButton.h
3 | // RTLButton
4 | //
5 | // Created by Anton Bukov on 22.05.15.
6 | // Copyright (c) 2015 Codeless Solutions. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | IB_DESIGNABLE
12 | @interface RTLButton : UIButton
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/RTLButton.m:
--------------------------------------------------------------------------------
1 | //
2 | // RTLButton.m
3 | // RTLButton
4 | //
5 | // Created by Anton Bukov on 22.05.15.
6 | // Copyright (c) 2015 Codeless Solutions. All rights reserved.
7 | //
8 |
9 | #import "RTLButton.h"
10 |
11 | @implementation RTLButton
12 |
13 | - (CGRect)imageRectForContentRect:(CGRect)contentRect
14 | {
15 | CGRect frame = [super imageRectForContentRect:contentRect];
16 | frame.origin.x = CGRectGetMaxX(contentRect) - CGRectGetWidth(frame) - self.imageEdgeInsets.right + self.imageEdgeInsets.left - frame.origin.x;
17 | return frame;
18 | }
19 |
20 | - (CGRect)titleRectForContentRect:(CGRect)contentRect
21 | {
22 | CGRect frame = [super titleRectForContentRect:contentRect];
23 | frame.origin.x = CGRectGetMinX(frame) - CGRectGetWidth([self imageRectForContentRect:contentRect]);
24 | return frame;
25 | }
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/RTLButton.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # Be sure to run `pod spec lint RTLButton.podspec' to ensure this is a
3 | # valid spec and to remove all comments including this before submitting the spec.
4 | #
5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
7 | #
8 |
9 | Pod::Spec.new do |s|
10 |
11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
12 | #
13 | # These will help people to find your library, and whilst it
14 | # can feel like a chore to fill in it's definitely to your advantage. The
15 | # summary should be tweet-length, and the description more in depth.
16 | #
17 |
18 | s.name = "RTLButton"
19 | s.version = "0.0.1"
20 | s.summary = "UIButton subclass with image and title aligned Right To Left"
21 |
22 | s.description = <<-DESC
23 | Wanna align image and text of UIButton in reverse order? Just use `RTLButton`
24 | and your button content will be right to left aligned even in storyboard :)
25 | DESC
26 |
27 | s.homepage = "https://github.com/k06a/RTLButton"
28 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
29 |
30 |
31 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
32 | #
33 | # Licensing your code is important. See http://choosealicense.com for more info.
34 | # CocoaPods will detect a license file if there is a named LICENSE*
35 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
36 | #
37 |
38 | s.license = "MIT"
39 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" }
40 |
41 |
42 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
43 | #
44 | # Specify the authors of the library, with email addresses. Email addresses
45 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
46 | # accepts just a name if you'd rather not provide an email address.
47 | #
48 | # Specify a social_media_url where others can refer to, for example a twitter
49 | # profile URL.
50 | #
51 |
52 | s.author = { "Anton Bukov" => "k06aaa@gmail.com" }
53 | # Or just: s.author = "Anton Bukov"
54 | # s.authors = { "Anton Bukov" => "k06aaa@gmail.com" }
55 | # s.social_media_url = "http://twitter.com/Anton Bukov"
56 |
57 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
58 | #
59 | # If this Pod runs only on iOS or OS X, then specify the platform and
60 | # the deployment target. You can optionally include the target after the platform.
61 | #
62 |
63 | s.platform = :ios
64 | # s.platform = :ios, "5.0"
65 |
66 | # When using multiple platforms
67 | # s.ios.deployment_target = "5.0"
68 | # s.osx.deployment_target = "10.7"
69 |
70 |
71 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
72 | #
73 | # Specify the location from where the source should be retrieved.
74 | # Supports git, hg, bzr, svn and HTTP.
75 | #
76 |
77 | s.source = { :git => "https://github.com/k06a/RTLButton.git", :tag => "0.0.1" }
78 |
79 |
80 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
81 | #
82 | # CocoaPods is smart about how it includes source code. For source files
83 | # giving a folder will include any swift, h, m, mm, c & cpp files.
84 | # For header files it will include any header in the folder.
85 | # Not including the public_header_files will make all headers public.
86 | #
87 |
88 | s.source_files = "*.{h,m}"
89 | # s.exclude_files = "Classes/Exclude"
90 |
91 | # s.public_header_files = "Classes/**/*.h"
92 |
93 |
94 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
95 | #
96 | # A list of resources included with the Pod. These are copied into the
97 | # target bundle with a build phase script. Anything else will be cleaned.
98 | # You can preserve files from being cleaned, please don't preserve
99 | # non-essential files like tests, examples and documentation.
100 | #
101 |
102 | # s.resource = "icon.png"
103 | # s.resources = "Resources/*.png"
104 |
105 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave"
106 |
107 |
108 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
109 | #
110 | # Link your library with frameworks, or libraries. Libraries do not include
111 | # the lib prefix of their name.
112 | #
113 |
114 | # s.framework = "SomeFramework"
115 | # s.frameworks = "SomeFramework", "AnotherFramework"
116 |
117 | # s.library = "iconv"
118 | # s.libraries = "iconv", "xml2"
119 |
120 |
121 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
122 | #
123 | # If your library depends on compiler flags you can set them in the xcconfig hash
124 | # where they will only apply to your library. If you depend on other Podspecs
125 | # you can include multiple dependencies to ensure it works.
126 |
127 | s.requires_arc = true
128 |
129 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
130 | # s.dependency "JSONKit", "~> 1.4"
131 |
132 | end
133 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/k06a/RTLButton/da764031ffb35f2015b08a08891197d5101bdd20/screenshot.png
--------------------------------------------------------------------------------