Skip to content

Commit

Permalink
Added support for RTL interface layout.
Browse files Browse the repository at this point in the history
Updated API comments.
  • Loading branch information
DavydLiu committed Apr 2, 2016
1 parent 4474c43 commit 95f2fb8
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 81 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ All notable changes to this project will be documented in this file.

---

## [1.4.7](https://github.com/DavydLiu/DLRadioButton/releases/tag/1.4.7) (04/02/2016)
* Added support for RTL interface layout.
* Updated API comments.

## [1.4.6](https://github.com/DavydLiu/DLRadioButton/releases/tag/1.4.6) (01/31/2016)
* Added support for Carthage.
* Updated example project.
* Organized folder structure.
* Added change log.
* Added change log.
4 changes: 2 additions & 2 deletions DLRadioButton.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DLRadioButton",
"version": "1.4.6",
"version": "1.4.7",
"summary": "A highly customizable Radio Button for iOS",
"description": "A highly customizable Radio Button for iOS.\n\n* Buttons are drew by UIBezierPath, customize it however you want.\n* You can also use pictures to indicate buttons' selection state.\n",
"homepage": "https://github.com/DavydLiu/DLRadioButton",
Expand All @@ -17,7 +17,7 @@
},
"source": {
"git": "https://github.com/DavydLiu/DLRadioButton.git",
"tag": "1.4.6"
"tag": "1.4.7"
},
"source_files": "DLRadioButton/**/*.{h,m}",
"exclude_files": "Classes/Exclude",
Expand Down
12 changes: 7 additions & 5 deletions DLRadioButton.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
634D5B511C5D8B0F00A3740D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0730;
ORGANIZATIONNAME = "David Liu";
TargetAttributes = {
634D5B591C5D8B0F00A3740D = {
Expand Down Expand Up @@ -266,14 +266,14 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
Expand All @@ -300,9 +300,9 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = NO;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -321,6 +321,7 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
Expand All @@ -341,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -456,6 +457,7 @@
63F965051C5ED24C00FFD1A2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
58 changes: 31 additions & 27 deletions DLRadioButton/DLRadioButton.h
Original file line number Diff line number Diff line change
@@ -1,85 +1,89 @@
#import <UIKit/UIKit.h>

/**
A hightly customizable Radio Button for iOS.
*/
* A hightly customizable Radio Button for iOS.
*/
IB_DESIGNABLE
@interface DLRadioButton : UIButton

/**@name Properties*/
/**
Container for holding other buttons in same group.
*/
* Container for holding other buttons in same group.
*/
@property (nonatomic) IBOutletCollection(DLRadioButton) NSArray *otherButtons;

/**
Size of icon, default is kDefaulIconSize.
*/
* Size of icon, default is kDefaulIconSize.
*/
@property (nonatomic) IBInspectable CGFloat iconSize;

/**
Color of icon, default is title color for current UIControlState.
* Color of icon, default is title color for current UIControlState.
*/
@property (nonatomic) IBInspectable UIColor *iconColor;

/**
Stroke width of icon, default is iconSize / 9.
* Stroke width of icon, default is iconSize / 9.
*/
@property (nonatomic) IBInspectable CGFloat iconStrokeWidth;

/**
Size of selection indicator, default is iconSize * 0.5.
* Size of selection indicator, default is iconSize * 0.5.
*/
@property (nonatomic) IBInspectable CGFloat indicatorSize;

/**
Color of selection indicator, default is title color for current UIControlState.
*/
* Color of selection indicator, default is title color for current UIControlState.
*/
@property (nonatomic) IBInspectable UIColor *indicatorColor;

/**
Margin width between icon and title, default is kDefaultMarginWidth.
* Margin width between icon and title, default is kDefaultMarginWidth.
*/
@property (nonatomic) IBInspectable CGFloat marginWidth;

/**
Whether icon on the right side, default is NO.
*/
@property (nonatomic, getter=isIconOnRight) IBInspectable BOOL iconOnRight;
* Whether icon on the right side, default is NO.
* @warning Please also set contentHorizontalAlignment to UIControlContentHorizontalAlignmentRight.
*/
@property (nonatomic, getter = isIconOnRight) IBInspectable BOOL iconOnRight;

/**
Whether use square icon, default is NO.
*/
@property (nonatomic, getter=isIconSquare) IBInspectable BOOL iconSquare;
* Whether use square icon, default is NO.
*/
@property (nonatomic, getter = isIconSquare) IBInspectable BOOL iconSquare;

/**
Image for radio button icon (optional).
* Image for radio button icon (optional).
*/
@property (nonatomic) IBInspectable UIImage *icon;

/**
Image for radio button icon when selected (optional).
* Image for radio button icon when selected (optional).
*/
@property (nonatomic) IBInspectable UIImage *iconSelected;

/**
Whether enable multiple selection, default is NO.
* Whether enable multiple selection, default is NO.
*/
@property (nonatomic, getter=isMultipleSelectionEnabled) BOOL multipleSelectionEnabled;
@property (nonatomic, getter = isMultipleSelectionEnabled) BOOL multipleSelectionEnabled;

/**
@return Selected button in same group.
* Finds out selected button in same group.
*
* @return Selected button.
*/
- (DLRadioButton *)selectedButton;

/**
@return Selected buttons in same group, use it only if multiple selection is enabled.
* Finds out selected buttons in same group, use it only if multiple selection is enabled.
*
* @return Selected buttons.
*/
- (NSArray *)selectedButtons;

/**
Clears selection for other buttons in in same group.
*/
* Clears selection for other buttons in in same group.
*/
- (void)deselectOtherButtons;

@end
20 changes: 16 additions & 4 deletions DLRadioButton/DLRadioButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

static const CGFloat kDefaulIconSize = 15.0;
static const CGFloat kDefaultMarginWidth = 5.0;
static NSString *const kGeneratedIconName = @"Generated Icon";
static NSString * const kGeneratedIconName = @"Generated Icon";
static BOOL _groupModifing = NO;

@implementation DLRadioButton
Expand Down Expand Up @@ -53,11 +53,23 @@ - (void)drawButton {
self.iconSelected = [self drawIconWithSelection:YES];
}
CGFloat marginWidth = self.marginWidth ? self.marginWidth : kDefaultMarginWidth;
BOOL isRightToLeftLayout = NO;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0) {
isRightToLeftLayout = [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft;
}
if (self.isIconOnRight) {
self.imageEdgeInsets = UIEdgeInsetsMake(0, self.frame.size.width - self.icon.size.width, 0, 0);
self.titleEdgeInsets = UIEdgeInsetsMake(0, -self.icon.size.width, 0, marginWidth + self.icon.size.width);
self.imageEdgeInsets = isRightToLeftLayout ?
UIEdgeInsetsMake(0, 0, 0, self.frame.size.width - self.icon.size.width) :
UIEdgeInsetsMake(0, self.frame.size.width - self.icon.size.width, 0, 0);
self.titleEdgeInsets = isRightToLeftLayout ?
UIEdgeInsetsMake(0, marginWidth + self.icon.size.width, 0, -self.icon.size.width) :
UIEdgeInsetsMake(0, -self.icon.size.width, 0, marginWidth + self.icon.size.width);
} else {
self.titleEdgeInsets = UIEdgeInsetsMake(0, marginWidth, 0, 0);
if (isRightToLeftLayout) {
self.imageEdgeInsets = UIEdgeInsetsMake(0, marginWidth, 0, 0);
} else {
self.titleEdgeInsets = UIEdgeInsetsMake(0, marginWidth, 0, 0);
}
}
}

Expand Down
Binary file modified Example/DLRadioButton.framework/DLRadioButton
Binary file not shown.
58 changes: 31 additions & 27 deletions Example/DLRadioButton.framework/Headers/DLRadioButton.h
Original file line number Diff line number Diff line change
@@ -1,85 +1,89 @@
#import <UIKit/UIKit.h>

/**
A hightly customizable Radio Button for iOS.
*/
* A hightly customizable Radio Button for iOS.
*/
IB_DESIGNABLE
@interface DLRadioButton : UIButton

/**@name Properties*/
/**
Container for holding other buttons in same group.
*/
* Container for holding other buttons in same group.
*/
@property (nonatomic) IBOutletCollection(DLRadioButton) NSArray *otherButtons;

/**
Size of icon, default is kDefaulIconSize.
*/
* Size of icon, default is kDefaulIconSize.
*/
@property (nonatomic) IBInspectable CGFloat iconSize;

/**
Color of icon, default is title color for current UIControlState.
* Color of icon, default is title color for current UIControlState.
*/
@property (nonatomic) IBInspectable UIColor *iconColor;

/**
Stroke width of icon, default is iconSize / 9.
* Stroke width of icon, default is iconSize / 9.
*/
@property (nonatomic) IBInspectable CGFloat iconStrokeWidth;

/**
Size of selection indicator, default is iconSize * 0.5.
* Size of selection indicator, default is iconSize * 0.5.
*/
@property (nonatomic) IBInspectable CGFloat indicatorSize;

/**
Color of selection indicator, default is title color for current UIControlState.
*/
* Color of selection indicator, default is title color for current UIControlState.
*/
@property (nonatomic) IBInspectable UIColor *indicatorColor;

/**
Margin width between icon and title, default is kDefaultMarginWidth.
* Margin width between icon and title, default is kDefaultMarginWidth.
*/
@property (nonatomic) IBInspectable CGFloat marginWidth;

/**
Whether icon on the right side, default is NO.
*/
@property (nonatomic, getter=isIconOnRight) IBInspectable BOOL iconOnRight;
* Whether icon on the right side, default is NO.
* @warning Please also set contentHorizontalAlignment to UIControlContentHorizontalAlignmentRight.
*/
@property (nonatomic, getter = isIconOnRight) IBInspectable BOOL iconOnRight;

/**
Whether use square icon, default is NO.
*/
@property (nonatomic, getter=isIconSquare) IBInspectable BOOL iconSquare;
* Whether use square icon, default is NO.
*/
@property (nonatomic, getter = isIconSquare) IBInspectable BOOL iconSquare;

/**
Image for radio button icon (optional).
* Image for radio button icon (optional).
*/
@property (nonatomic) IBInspectable UIImage *icon;

/**
Image for radio button icon when selected (optional).
* Image for radio button icon when selected (optional).
*/
@property (nonatomic) IBInspectable UIImage *iconSelected;

/**
Whether enable multiple selection, default is NO.
* Whether enable multiple selection, default is NO.
*/
@property (nonatomic, getter=isMultipleSelectionEnabled) BOOL multipleSelectionEnabled;
@property (nonatomic, getter = isMultipleSelectionEnabled) BOOL multipleSelectionEnabled;

/**
@return Selected button in same group.
* Finds out selected button in same group.
*
* @return Selected button.
*/
- (DLRadioButton *)selectedButton;

/**
@return Selected buttons in same group, use it only if multiple selection is enabled.
* Finds out selected buttons in same group, use it only if multiple selection is enabled.
*
* @return Selected buttons.
*/
- (NSArray *)selectedButtons;

/**
Clears selection for other buttons in in same group.
*/
* Clears selection for other buttons in in same group.
*/
- (void)deselectOtherButtons;

@end
Binary file modified Example/DLRadioButton.framework/Info.plist
Binary file not shown.
6 changes: 3 additions & 3 deletions Example/DLRadioButton.framework/_CodeSignature/CodeResources
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<dict>
<key>Headers/DLRadioButton.h</key>
<data>
c0yBQwfclgj8rnPAB/LpTxzzhtE=
AUTpUW+3DpeB/74Awfr3kVxsj5U=
</data>
<key>Info.plist</key>
<data>
2cSbAYtvpdbDjdRkDU8MDAaHQQo=
UWWN2PR9W5RaAhlcmepNLPp+7rE=
</data>
<key>Modules/module.modulemap</key>
<data>
Expand All @@ -21,7 +21,7 @@
<dict>
<key>Headers/DLRadioButton.h</key>
<data>
c0yBQwfclgj8rnPAB/LpTxzzhtE=
AUTpUW+3DpeB/74Awfr3kVxsj5U=
</data>
<key>Modules/module.modulemap</key>
<data>
Expand Down
Loading

0 comments on commit 95f2fb8

Please sign in to comment.