Skip to content

Commit

Permalink
Fixed offset, added ability to pass an array of images and color. #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Friend-LGA committed Oct 24, 2015
1 parent a25a88e commit 13341c7
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 10 deletions.
21 changes: 20 additions & 1 deletion Demo/LGPlusButtonsViewDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
84C5B7C41A9F22C800EEEB24 /* Frameworks */,
84C5B7C51A9F22C800EEEB24 /* Resources */,
92F9790D16709FEEE544F8D3 /* Copy Pods Resources */,
F9E826B8E08EA21BF3C0A16C /* Embed Pods Frameworks */,
);
buildRules = (
);
Expand All @@ -164,7 +165,7 @@
84C5B7BF1A9F22C800EEEB24 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0610;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Grigory Lutkov";
TargetAttributes = {
84C5B7C61A9F22C800EEEB24 = {
Expand Down Expand Up @@ -232,6 +233,21 @@
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
F9E826B8E08EA21BF3C0A16C /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-LGPlusButtonsViewDemo/Pods-LGPlusButtonsViewDemo-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -271,6 +287,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -340,6 +357,7 @@
INFOPLIST_FILE = LGPlusButtonsViewDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.test.$(PRODUCT_NAME)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -355,6 +373,7 @@
INFOPLIST_FILE = LGPlusButtonsViewDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.test.$(PRODUCT_NAME)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "112560B489B85D419BBDB1910B347435FE176202",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {

},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"8C7BAE8A443A6327026687B5FEAD2A6BED527DDD" : 0,
"112560B489B85D419BBDB1910B347435FE176202" : 0
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "FD3D3D87-9EF8-43C4-A508-88C3E1ECD2E3",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"8C7BAE8A443A6327026687B5FEAD2A6BED527DDD" : "LGDrawer",
"112560B489B85D419BBDB1910B347435FE176202" : "LGPlusButtonsView"
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "LGPlusButtonsViewDemo",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "Demo\/LGPlusButtonsViewDemo.xcworkspace",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Friend-LGA\/LGPlusButtonsView.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "112560B489B85D419BBDB1910B347435FE176202"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Friend-LGA\/LGDrawer.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "8C7BAE8A443A6327026687B5FEAD2A6BED527DDD"
}
]
}
2 changes: 1 addition & 1 deletion Demo/LGPlusButtonsViewDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.test.$(PRODUCT_NAME)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
12 changes: 5 additions & 7 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
PODS:
- LGDrawer (1.0.0)
- LGPlusButtonsView (1.0.0)
- LGPlusButtonsView (1.0.4)

DEPENDENCIES:
- LGDrawer (from `../../LGDrawer`)
- LGDrawer (~> 1.0.0)
- LGPlusButtonsView (from `../`)

EXTERNAL SOURCES:
LGDrawer:
:path: ../../LGDrawer
LGPlusButtonsView:
:path: ../

SPEC CHECKSUMS:
LGDrawer: 7ceea97b27a6b23e8eb691210ca180c897025513
LGPlusButtonsView: a3a7d0c47f99dcce30911541f8d2d255244ab645
LGDrawer: 14fa657d7e21842797a6187c44d5a913841d34a8
LGPlusButtonsView: 7a913d5c6670ade0924073b68c482b2f013980c6

COCOAPODS: 0.37.2
COCOAPODS: 0.39.0
2 changes: 1 addition & 1 deletion LGPlusButtonsView.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'LGPlusButtonsView'
s.version = '1.0.3'
s.version = '1.0.4'
s.platform = :ios, '6.0'
s.license = 'MIT'
s.homepage = 'https://github.com/Friend-LGA/LGPlusButtonsView'
Expand Down
3 changes: 3 additions & 0 deletions LGPlusButtonsView/LGPlusButtonsView.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ LGPlusButtonAnimationType;
- (void)setButtonsTitles:(NSArray *)titles forState:(UIControlState)state;
- (void)setButtonsTitleColor:(UIColor *)titleColor forState:(UIControlState)state;
- (void)setButtonsImage:(UIImage *)image forState:(UIControlState)state;
- (void)setButtonsImages:(NSArray *)images forState:(UIControlState)state;
- (void)setButtonsBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state;
- (void)setButtonsBackgroundImages:(NSArray *)backgroundImages forState:(UIControlState)state;
- (void)setButtonsBackgroundColor:(UIColor *)backgroundColor forState:(UIControlState)state;
- (void)setButtonsBackgroundColors:(NSArray *)backgroundColors forState:(UIControlState)state;
- (void)setButtonsTitleFont:(UIFont *)font;

#pragma mark -
Expand Down
42 changes: 42 additions & 0 deletions LGPlusButtonsView/LGPlusButtonsView.m
Original file line number Diff line number Diff line change
Expand Up @@ -383,18 +383,58 @@ - (void)setButtonsImage:(UIImage *)image forState:(UIControlState)state
if (isChanged) [self layoutInvalidate];
}

- (void)setButtonsImages:(NSArray *)images forState:(UIControlState)state
{
BOOL isChanged = NO;

for (NSUInteger i=0; i<_buttons.count; i++)
{
LGPlusButton *button = _buttons[i];
UIImage *image = images[i];

if (!CGSizeEqualToSize(button.imageView.image.size, image.size))
isChanged = YES;

[button setImage:image forState:state];
}

if (isChanged) [self layoutInvalidate];
}

- (void)setButtonsBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state
{
for (LGPlusButton *button in _buttons)
[button setBackgroundImage:backgroundImage forState:state];
}

- (void)setButtonsBackgroundImages:(NSArray *)backgroundImages forState:(UIControlState)state
{
for (NSUInteger i=0; i<_buttons.count; i++)
{
LGPlusButton *button = _buttons[i];
UIImage *backgroundImage = backgroundImages[i];

[button setBackgroundImage:backgroundImage forState:state];
}
}

- (void)setButtonsBackgroundColor:(UIColor *)backgroundColor forState:(UIControlState)state
{
for (LGPlusButton *button in _buttons)
[button setBackgroundColor:backgroundColor forState:state];
}

- (void)setButtonsBackgroundColors:(NSArray *)backgroundColors forState:(UIControlState)state
{
for (NSUInteger i=0; i<_buttons.count; i++)
{
LGPlusButton *button = _buttons[i];
UIColor *backgroundColor = backgroundColors[i];

[button setBackgroundColor:backgroundColor forState:state];
}
}

- (void)setButtonsTitleFont:(UIFont *)font
{
BOOL isChanged = NO;
Expand Down Expand Up @@ -878,6 +918,8 @@ - (void)updatePosition
selfOrigin = CGPointMake(parentInset.left+parentOffset.x,
parentInset.top+parentOffset.y);
}
selfOrigin.x += _offset.x;
selfOrigin.y += _offset.y;

CGRect selfFrame = CGRectMake(selfOrigin.x, selfOrigin.y, self.frame.size.width, self.frame.size.height);
if ([UIScreen mainScreen].scale == 1.f) selfFrame = CGRectIntegral(selfFrame);
Expand Down

0 comments on commit 13341c7

Please sign in to comment.