Skip to content

Commit

Permalink
commit SJShimmeringText method
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjcom authored and hsjcom committed Apr 22, 2015
1 parent f9fac15 commit d6386dc
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 0 deletions.
8 changes: 8 additions & 0 deletions SoldierShimmering.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
B2C462B31AE64E91008EAF43 /* SoldierShimmeringTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B2C462B21AE64E91008EAF43 /* SoldierShimmeringTests.m */; };
B2C462C21AE64EF7008EAF43 /* FBShimmeringLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = B2C462BF1AE64EF7008EAF43 /* FBShimmeringLayer.m */; };
B2C462C31AE64EF7008EAF43 /* FBShimmeringView.m in Sources */ = {isa = PBXBuildFile; fileRef = B2C462C11AE64EF7008EAF43 /* FBShimmeringView.m */; };
B2C462CC1AE77FD4008EAF43 /* SJShimmeringText.m in Sources */ = {isa = PBXBuildFile; fileRef = B2C462CB1AE77FD4008EAF43 /* SJShimmeringText.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -47,6 +48,8 @@
B2C462BF1AE64EF7008EAF43 /* FBShimmeringLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBShimmeringLayer.m; sourceTree = "<group>"; };
B2C462C01AE64EF7008EAF43 /* FBShimmeringView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBShimmeringView.h; sourceTree = "<group>"; };
B2C462C11AE64EF7008EAF43 /* FBShimmeringView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBShimmeringView.m; sourceTree = "<group>"; };
B2C462CA1AE77FD4008EAF43 /* SJShimmeringText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SJShimmeringText.h; path = SoldierShimmering/SJShimmeringText.h; sourceTree = SOURCE_ROOT; };
B2C462CB1AE77FD4008EAF43 /* SJShimmeringText.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SJShimmeringText.m; path = SoldierShimmering/SJShimmeringText.m; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -94,6 +97,8 @@
B2C4629D1AE64E91008EAF43 /* ViewController.h */,
B2C4629E1AE64E91008EAF43 /* ViewController.m */,
B2C462A01AE64E91008EAF43 /* Main.storyboard */,
B2C462CA1AE77FD4008EAF43 /* SJShimmeringText.h */,
B2C462CB1AE77FD4008EAF43 /* SJShimmeringText.m */,
B2C462A31AE64E91008EAF43 /* Images.xcassets */,
B2C462A51AE64E91008EAF43 /* LaunchScreen.xib */,
B2C462961AE64E91008EAF43 /* Supporting Files */,
Expand Down Expand Up @@ -239,6 +244,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B2C462CC1AE77FD4008EAF43 /* SJShimmeringText.m in Sources */,
B2C4629F1AE64E91008EAF43 /* ViewController.m in Sources */,
B2C4629C1AE64E91008EAF43 /* AppDelegate.m in Sources */,
B2C462C21AE64EF7008EAF43 /* FBShimmeringLayer.m in Sources */,
Expand Down Expand Up @@ -436,6 +442,7 @@
B2C462B81AE64E91008EAF43 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
B2C462B91AE64E91008EAF43 /* Build configuration list for PBXNativeTarget "SoldierShimmeringTests" */ = {
isa = XCConfigurationList;
Expand All @@ -444,6 +451,7 @@
B2C462BB1AE64E91008EAF43 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>FFD60FBB-7A01-4D98-A0A5-5AB01686617A</string>
<key>IDESourceControlProjectName</key>
<string>SoldierShimmering</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>704DFF3E648870946D5AD5850B8869B435FF17A9</key>
<string>https://github.com/hsjcom/SoldierShimmering.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>SoldierShimmering.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>704DFF3E648870946D5AD5850B8869B435FF17A9</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/hsjcom/SoldierShimmering.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>704DFF3E648870946D5AD5850B8869B435FF17A9</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>704DFF3E648870946D5AD5850B8869B435FF17A9</string>
<key>IDESourceControlWCCName</key>
<string>SoldierShimmering</string>
</dict>
</array>
</dict>
</plist>
22 changes: 22 additions & 0 deletions SoldierShimmering/SJShimmeringText.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// SJShimmeringText.h
// SoldierShimmering
//
// Created by Soldier on 15/4/22.
// Copyright (c) 2015年 Soldier. All rights reserved.
//

#import "FBShimmeringView.h"
#import <UIKit/UIKit.h>

@interface SJShimmeringText : FBShimmeringView

@property(nonatomic, strong) UILabel *textLabel;

- (instancetype)initWithFrame:(CGRect)frame
text:(NSString *)text
font:(UIFont *)font
textColor:(UIColor *)textColor
textAlignment:(NSTextAlignment)textAlignment;

@end
38 changes: 38 additions & 0 deletions SoldierShimmering/SJShimmeringText.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// SJShimmeringText.m
// SoldierShimmering
//
// Created by Soldier on 15/4/22.
// Copyright (c) 2015年 Soldier. All rights reserved.
//

#import "SJShimmeringText.h"

@implementation SJShimmeringText

- (instancetype)initWithFrame:(CGRect)frame
text:(NSString *)text
font:(UIFont *)font
textColor:(UIColor *)textColor
textAlignment:(NSTextAlignment)textAlignment {
self = [super initWithFrame:frame];
if (self) {
self.shimmering = YES;
self.shimmeringBeginFadeDuration = 0.3;
self.shimmeringOpacity = 0.3;
self.shimmeringSpeed = 230;

_textLabel = [[UILabel alloc] initWithFrame:frame];
_textLabel.text = text;
_textLabel.font = font;
_textLabel.textColor = textColor;
_textLabel.textAlignment = textAlignment;
[_textLabel sizeToFit];
_textLabel.frame = CGRectMake(0, 0, _textLabel.frame.size.width, _textLabel.frame.size.height);
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, _textLabel.frame.size.width, _textLabel.frame.size.height);
self.contentView = _textLabel;
}
return self;
}

@end
11 changes: 11 additions & 0 deletions SoldierShimmering/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "ViewController.h"
#import "FBShimmeringView.h"
#import "SJShimmeringText.h"

@interface ViewController () {
FBShimmeringView *_shimmeringView;
Expand All @@ -30,6 +31,9 @@ - (void)viewDidLoad {
}

- (void)textDisplay {
/*
* FBShimmeringView
*/
_shimmeringView = [[FBShimmeringView alloc] init];
_shimmeringView.shimmering = YES;
_shimmeringView.shimmeringBeginFadeDuration = 0.3;
Expand All @@ -49,6 +53,13 @@ - (void)textDisplay {

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
[self.view addGestureRecognizer:tapRecognizer];


/*
* SJShimmeringText
*/
SJShimmeringText *text = [[SJShimmeringText alloc] initWithFrame:CGRectMake(0, _shimmeringView.frame.origin.y + _shimmeringView.frame.size.height + 40, self.view.frame.size.width, 10) text:@"Viva La Vida " font:[UIFont systemFontOfSize:55] textColor:[UIColor yellowColor] textAlignment:NSTextAlignmentCenter];
[self.view addSubview:text];
}

- (void)viewDisplay {
Expand Down

0 comments on commit d6386dc

Please sign in to comment.