Skip to content

Commit 24669b4

Browse files
wanghenghengEase
authored and
Ease
committed
通知中心改版
1 parent 46498de commit 24669b4

30 files changed

+234
-166
lines changed

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@
144144
4E38CF5F1A7A28AF005536C0 /* CodeBranchTagButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E38CF5E1A7A28AF005536C0 /* CodeBranchTagButton.m */; };
145145
4E38CF621A7B7C99005536C0 /* CodeBranchOrTag.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E38CF611A7B7C99005536C0 /* CodeBranchOrTag.m */; };
146146
4E38CF641A7B8DD4005536C0 /* icon_triangle@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E38CF631A7B8DD4005536C0 /* icon_triangle@2x.png */; };
147+
4E4972DC1BB52A8300F3AC15 /* tipIcon_TweetComment@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E4972DB1BB52A8300F3AC15 /* tipIcon_TweetComment@2x.png */; settings = {ASSET_TAGS = (); }; };
148+
4E4972DF1BB535B400F3AC15 /* tipIcon_ProjectTweet@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E4972DD1BB535B400F3AC15 /* tipIcon_ProjectTweet@2x.png */; settings = {ASSET_TAGS = (); }; };
149+
4E4972E01BB535B400F3AC15 /* tipIcon_ProjectTweetComment@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E4972DE1BB535B400F3AC15 /* tipIcon_ProjectTweetComment@2x.png */; settings = {ASSET_TAGS = (); }; };
147150
4E4ABBEA1A653027004760D9 /* WebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E4ABBE91A653027004760D9 /* WebViewController.m */; };
148151
4E4D6A581B1C5DC000FD2E49 /* MRPRCommentCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E4D6A571B1C5DC000FD2E49 /* MRPRCommentCell.m */; };
149152
4E4D6A5B1B1C5DDF00FD2E49 /* MRPRCommentCCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E4D6A5A1B1C5DDF00FD2E49 /* MRPRCommentCCell.m */; };
@@ -273,7 +276,6 @@
273276
4E715A321BB1278200A5D24B /* LocalFolderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E715A311BB1278200A5D24B /* LocalFolderCell.m */; settings = {ASSET_TAGS = (); }; };
274277
4E715A351BB1279D00A5D24B /* LocalFileCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E715A341BB1279D00A5D24B /* LocalFileCell.m */; settings = {ASSET_TAGS = (); }; };
275278
4E72F82D1B144778001B6CE6 /* NSMutableString+Common.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E72F82C1B144778001B6CE6 /* NSMutableString+Common.m */; };
276-
4E72F82F1B159997001B6CE6 /* tipIcon_Other@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E72F82E1B159997001B6CE6 /* tipIcon_Other@2x.png */; };
277279
4E72F8331B15B811001B6CE6 /* gif_mark@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E72F8321B15B811001B6CE6 /* gif_mark@2x.png */; };
278280
4E743E6D1A88A3CC00DADDE5 /* EaseMarkdownTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E743E6C1A88A3CC00DADDE5 /* EaseMarkdownTextView.m */; };
279281
4E743E6F1A88ABF700DADDE5 /* blankpage_image_Hi@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E743E6E1A88ABF700DADDE5 /* blankpage_image_Hi@2x.png */; };
@@ -791,7 +793,6 @@
791793
8EA6D19C19E240C40076D59C /* tipIcon_QcTask@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EA6CFB719E240C40076D59C /* tipIcon_QcTask@2x.png */; };
792794
8EA6D19D19E240C40076D59C /* tipIcon_Task@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EA6CFB819E240C40076D59C /* tipIcon_Task@2x.png */; };
793795
8EA6D19E19E240C40076D59C /* tipIcon_Tweet@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EA6CFB919E240C40076D59C /* tipIcon_Tweet@2x.png */; };
794-
8EA6D19F19E240C40076D59C /* tipIcon_TweetComment@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EA6CFBA19E240C40076D59C /* tipIcon_TweetComment@2x.png */; };
795796
8EA6D1A019E240C40076D59C /* tipIcon_TweetLike@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EA6CFBB19E240C40076D59C /* tipIcon_TweetLike@2x.png */; };
796797
8EA6D1A119E240C40076D59C /* tipIcon_UserFollow@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EA6CFBC19E240C40076D59C /* tipIcon_UserFollow@2x.png */; };
797798
8EA6D1A319E240C40076D59C /* tweet_comment_btn@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EA6CFBE19E240C40076D59C /* tweet_comment_btn@2x.png */; };
@@ -1115,6 +1116,9 @@
11151116
4E38CF601A7B7C99005536C0 /* CodeBranchOrTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeBranchOrTag.h; sourceTree = "<group>"; };
11161117
4E38CF611A7B7C99005536C0 /* CodeBranchOrTag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CodeBranchOrTag.m; sourceTree = "<group>"; };
11171118
4E38CF631A7B8DD4005536C0 /* icon_triangle@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_triangle@2x.png"; sourceTree = "<group>"; };
1119+
4E4972DB1BB52A8300F3AC15 /* tipIcon_TweetComment@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tipIcon_TweetComment@2x.png"; sourceTree = "<group>"; };
1120+
4E4972DD1BB535B400F3AC15 /* tipIcon_ProjectTweet@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tipIcon_ProjectTweet@2x.png"; sourceTree = "<group>"; };
1121+
4E4972DE1BB535B400F3AC15 /* tipIcon_ProjectTweetComment@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tipIcon_ProjectTweetComment@2x.png"; sourceTree = "<group>"; };
11181122
4E4ABBE81A653027004760D9 /* WebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewController.h; sourceTree = "<group>"; };
11191123
4E4ABBE91A653027004760D9 /* WebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewController.m; sourceTree = "<group>"; };
11201124
4E4D6A561B1C5DC000FD2E49 /* MRPRCommentCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MRPRCommentCell.h; sourceTree = "<group>"; };
@@ -1311,7 +1315,6 @@
13111315
4E715A341BB1279D00A5D24B /* LocalFileCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocalFileCell.m; sourceTree = "<group>"; };
13121316
4E72F82B1B144778001B6CE6 /* NSMutableString+Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableString+Common.h"; sourceTree = "<group>"; };
13131317
4E72F82C1B144778001B6CE6 /* NSMutableString+Common.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableString+Common.m"; sourceTree = "<group>"; };
1314-
4E72F82E1B159997001B6CE6 /* tipIcon_Other@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tipIcon_Other@2x.png"; sourceTree = "<group>"; };
13151318
4E72F8321B15B811001B6CE6 /* gif_mark@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "gif_mark@2x.png"; sourceTree = "<group>"; };
13161319
4E743E6B1A88A3CC00DADDE5 /* EaseMarkdownTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EaseMarkdownTextView.h; sourceTree = "<group>"; };
13171320
4E743E6C1A88A3CC00DADDE5 /* EaseMarkdownTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EaseMarkdownTextView.m; sourceTree = "<group>"; };
@@ -2072,7 +2075,6 @@
20722075
8EA6CFB719E240C40076D59C /* tipIcon_QcTask@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tipIcon_QcTask@2x.png"; sourceTree = "<group>"; };
20732076
8EA6CFB819E240C40076D59C /* tipIcon_Task@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tipIcon_Task@2x.png"; sourceTree = "<group>"; };
20742077
8EA6CFB919E240C40076D59C /* tipIcon_Tweet@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tipIcon_Tweet@2x.png"; sourceTree = "<group>"; };
2075-
8EA6CFBA19E240C40076D59C /* tipIcon_TweetComment@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tipIcon_TweetComment@2x.png"; sourceTree = "<group>"; };
20762078
8EA6CFBB19E240C40076D59C /* tipIcon_TweetLike@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tipIcon_TweetLike@2x.png"; sourceTree = "<group>"; };
20772079
8EA6CFBC19E240C40076D59C /* tipIcon_UserFollow@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tipIcon_UserFollow@2x.png"; sourceTree = "<group>"; };
20782080
8EA6CFBE19E240C40076D59C /* tweet_comment_btn@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tweet_comment_btn@2x.png"; sourceTree = "<group>"; };
@@ -4097,10 +4099,11 @@
40974099
8EA6CFB819E240C40076D59C /* tipIcon_Task@2x.png */,
40984100
8E7612F31A08B1EA005BE797 /* tipIcon_TaskComment@2x.png */,
40994101
8EA6CFB919E240C40076D59C /* tipIcon_Tweet@2x.png */,
4100-
8EA6CFBA19E240C40076D59C /* tipIcon_TweetComment@2x.png */,
41014102
8EA6CFBB19E240C40076D59C /* tipIcon_TweetLike@2x.png */,
41024103
8EA6CFBC19E240C40076D59C /* tipIcon_UserFollow@2x.png */,
4103-
4E72F82E1B159997001B6CE6 /* tipIcon_Other@2x.png */,
4104+
4E4972DB1BB52A8300F3AC15 /* tipIcon_TweetComment@2x.png */,
4105+
4E4972DD1BB535B400F3AC15 /* tipIcon_ProjectTweet@2x.png */,
4106+
4E4972DE1BB535B400F3AC15 /* tipIcon_ProjectTweetComment@2x.png */,
41044107
);
41054108
path = tip_icons;
41064109
sourceTree = "<group>";
@@ -4771,10 +4774,12 @@
47714774
4E2BF3D41B96CDF800A5A0A8 /* share_btn_sina@2x.png in Resources */,
47724775
8E8F7B2F19EF6306006BA8BD /* btn_privateMsg_black@2x.png in Resources */,
47734776
4E96E7E01A1B537E0037C098 /* icon_file_pdf@2x.png in Resources */,
4777+
4E4972DC1BB52A8300F3AC15 /* tipIcon_TweetComment@2x.png in Resources */,
47744778
4EFE8DAC1B394A0D004B7559 /* file_changeType_COPY@2x.png in Resources */,
47754779
4E996C071ABBF56A00C704F1 /* user_info_detail@2x.png in Resources */,
47764780
4E8C51B01AC1081500B4C51F /* icon_recommended@2x.png in Resources */,
47774781
4E96E7DA1A1B537E0037C098 /* icon_file_doc@2x.png in Resources */,
4782+
4E4972DF1BB535B400F3AC15 /* tipIcon_ProjectTweet@2x.png in Resources */,
47784783
8E62ADDA19E28DA800963870 /* tipIcon_User@2x.png in Resources */,
47794784
4E6383A71B3262D300D98648 /* taskPriority0_small@2x.png in Resources */,
47804785
8E8F7B3519EF6306006BA8BD /* btn_project_quit@2x.png in Resources */,
@@ -4839,7 +4844,6 @@
48394844
0A782FDE1AB5B78B00E96661 /* TweetSendCreateLocationCell.xib in Resources */,
48404845
8E8F7B3219EF6306006BA8BD /* btn_privateMsg_white@2x.png in Resources */,
48414846
8E97CEBB1A0C7E26006F9AD7 /* coding_emoji_36@2x.png in Resources */,
4842-
8EA6D19F19E240C40076D59C /* tipIcon_TweetComment@2x.png in Resources */,
48434847
4E996C041ABBF56A00C704F1 /* n_btn_followed_yes@2x.png in Resources */,
48444848
4EAE06901B784E9200179F4B /* store_icon@2x.png in Resources */,
48454849
4EF818161B049C89005F974B /* addPictureBgImage@2x.png in Resources */,
@@ -4888,9 +4892,9 @@
48884892
4EF17EDF1B3C3112003CDD2D /* intro_tip_1@3x.png in Resources */,
48894893
4E94C50E1B4D334B00EB668A /* pop_User@2x.png in Resources */,
48904894
4EFE8DAF1B3960E6004B7559 /* logo_coding_top@2x.png in Resources */,
4895+
4E4972E01BB535B400F3AC15 /* tipIcon_ProjectTweetComment@2x.png in Resources */,
48914896
4E66EE261A28226000DA1B3E /* button_file_createFolder_enable@2x.png in Resources */,
48924897
8EA6D19C19E240C40076D59C /* tipIcon_QcTask@2x.png in Resources */,
4893-
4E72F82F1B159997001B6CE6 /* tipIcon_Other@2x.png in Resources */,
48944898
4E095A841B6B24DE008DC439 /* time_clock_icon@2x.png in Resources */,
48954899
4E6383FC1B33C18700D98648 /* task_activity_icon_reassign@2x.png in Resources */,
48964900
4E6383B71B32640900D98648 /* messageAT@2x.png in Resources */,
@@ -5738,6 +5742,7 @@
57385742
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
57395743
CODE_SIGN_IDENTITY = "iPhone Developer";
57405744
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
5745+
ENABLE_BITCODE = NO;
57415746
FRAMEWORK_SEARCH_PATHS = (
57425747
"$(inherited)",
57435748
"$(PROJECT_DIR)",
@@ -5773,6 +5778,7 @@
57735778
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
57745779
CODE_SIGN_IDENTITY = "iPhone Developer";
57755780
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
5781+
ENABLE_BITCODE = NO;
57765782
FRAMEWORK_SEARCH_PATHS = (
57775783
"$(inherited)",
57785784
"$(PROJECT_DIR)",

Coding_iOS/.DS_Store

0 Bytes
Binary file not shown.

Coding_iOS/Images/tip_icons/tipIcon_BranchMember@2x.png

100755100644
-1.17 KB
Loading
-1.49 KB
Loading
-1.49 KB
Loading
-2.03 KB
Binary file not shown.

Coding_iOS/Images/tip_icons/tipIcon_Project@2x.png

100755100644
-1.47 KB
Loading
-1.17 KB
Loading

Coding_iOS/Images/tip_icons/tipIcon_ProjectTopic@2x.png

100755100644
-1.54 KB
Loading
Loading
Loading
-1.54 KB
Loading
-1.54 KB
Loading

Coding_iOS/Images/tip_icons/tipIcon_QcTask@2x.png

100755100644
-1.59 KB
Loading

Coding_iOS/Images/tip_icons/tipIcon_Task@2x.png

100755100644
-1.81 KB
Loading

Coding_iOS/Images/tip_icons/tipIcon_TaskComment@2x.png

100755100644
-1.81 KB
Loading

Coding_iOS/Images/tip_icons/tipIcon_Tweet@2x.png

100755100644
-1.4 KB
Loading

Coding_iOS/Images/tip_icons/tipIcon_TweetComment@2x.png

100755100644
-1.26 KB
Loading

Coding_iOS/Images/tip_icons/tipIcon_TweetLike@2x.png

100755100644
-1.44 KB
Loading

Coding_iOS/Images/tip_icons/tipIcon_User@2x.png

100755100644
-1.49 KB
Loading

Coding_iOS/Images/tip_icons/tipIcon_UserFollow@2x.png

100755100644
-1.38 KB
Loading

Coding_iOS/Models/CodingTip.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@
1818
@property (readwrite, nonatomic, strong) NSString *content, *target_type;
1919
@property (readwrite, nonatomic, strong) HtmlMedia *htmlMedia;
2020

21+
@property (strong, nonatomic) HtmlMediaItem *target_item, *user_item;
22+
@property (strong, nonatomic) NSString *target_type_imageName, *target_type_ColorName;
2123
@end

Coding_iOS/Models/CodingTip.m

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,65 @@ - (void)setContent:(NSString *)content{
1515
_htmlMedia = [HtmlMedia htmlMediaWithString:content showType:MediaShowTypeImageAndMonkey];
1616
_content = _htmlMedia.contentDisplay;
1717
}
18+
if (_target_type.length > 0) {
19+
[self adjust];
20+
}
21+
}
22+
23+
- (void)setTarget_type:(NSString *)target_type{
24+
_target_type = target_type;
25+
if (_content.length > 0) {
26+
[self adjust];
27+
}
28+
}
29+
30+
- (void)adjust{
31+
//根据 content、target_type 去重组数据
32+
if (_htmlMedia.mediaItems.count > 0) {
33+
_user_item = [_htmlMedia.mediaItems firstObject];
34+
[_htmlMedia removeItem:_user_item];
35+
}
36+
if (_htmlMedia.mediaItems.count > 0) {
37+
_target_item = [_htmlMedia.mediaItems lastObject];
38+
[_htmlMedia removeItem:_target_item];
39+
}
40+
_target_type_ColorName = [[CodingTip p_color_dict] objectForKey:_target_type];
41+
if (_target_type_ColorName.length <= 0) {
42+
_target_type_ColorName = @"0x379FD3";
43+
}
44+
_target_type_imageName = [NSString stringWithFormat:@"tipIcon_%@", _target_type];
45+
_content = _htmlMedia.contentDisplay;
46+
}
47+
48+
+ (NSDictionary *)p_color_dict{
49+
static NSDictionary *color_dict = nil;
50+
static dispatch_once_t onceToken;
51+
dispatch_once(&onceToken, ^{
52+
color_dict = @{
53+
@"BranchMember" : @"0x1AB6D9",
54+
@"CommitLineNote" : @"",
55+
@"Depot" : @"",
56+
@"MergeRequestBean" : @"0x4E74B7",
57+
@"MergeRequestComment" : @"0x4E74B7",
58+
@"Project" : @"0xF8BE46",
59+
@"ProjectFileComment" : @"",
60+
@"ProjectMember" : @"0x1AB6D9",
61+
@"ProjectPayment" : @"",
62+
@"ProjectTopic" : @"0x2FAEEA",
63+
@"ProjectTweet" : @"0xFB8638",
64+
@"ProjectTweetComment" : @"0xFB8638",
65+
@"PullRequestBean" : @"0x49C9A7",
66+
@"PullRequestComment" : @"0x49C9A7",
67+
@"QcTask" : @"0x3C8CEA",
68+
@"Task" : @"0x379FD3",
69+
@"TaskComment" : @"0x379FD3",
70+
@"Tweet" : @"0xFB8638",
71+
@"TweetComment" : @"0xFB8638",
72+
@"TweetLike" : @"0xFF5847",
73+
@"User" : @"0x496AB3",
74+
@"UserFollow" : @"0x3BBD79",
75+
};
76+
});
77+
return color_dict;
1878
}
1979
@end

Coding_iOS/Models/HtmlMedia.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ typedef NS_ENUM(NSInteger, MediaShowType) {
3636
@property (readwrite, nonatomic, strong) NSMutableString *contentDisplay;
3737
@property (readwrite, nonatomic, strong) NSMutableArray *mediaItems;
3838
@property (strong, nonatomic) NSArray *imageItems;
39+
- (void)removeItem:(HtmlMediaItem *)item;
3940

4041
+ (instancetype)htmlMediaWithString:(NSString *)htmlString showType:(MediaShowType)showType;
4142
- (instancetype)initWithString:(NSString *)htmlString showType:(MediaShowType)showType;

Coding_iOS/Models/HtmlMedia.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,23 @@ - (void)analyseHtmlElement:(TFHppleElement* )element withShowType:(MediaShowType
144144
}
145145
}
146146

147+
- (void)removeItem:(HtmlMediaItem *)delItem{
148+
NSInteger index = [_mediaItems indexOfObject:delItem];
149+
if (index != NSNotFound) {
150+
if (delItem.range.length > 0) {
151+
[_mediaItems enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(HtmlMediaItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
152+
if (idx > index) {
153+
obj.range = NSMakeRange(obj.range.location - delItem.range.length, obj.range.length);
154+
}else{
155+
*stop = YES;
156+
}
157+
}];
158+
[_contentDisplay replaceCharactersInRange:delItem.range withString:@""];
159+
}
160+
[_mediaItems removeObject:delItem];
161+
}
162+
}
163+
147164
+ (instancetype)htmlMediaWithString:(NSString *)htmlString showType:(MediaShowType)showType{
148165
return [[[self class] alloc] initWithString:htmlString showType:showType];
149166
}

Coding_iOS/Util/Common/UIBadgeView.m

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,10 @@ - (void)drawRect:(CGRect)rect
157157
}
158158
}
159159

160-
CGContextSetFillColorWithColor(context, [[self badgeTextColor] CGColor]);
161-
162-
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
160+
//badgeValue
161+
if (![self.badgeValue isEqualToString:kBadgeTipStr]) {
162+
CGContextSetFillColorWithColor(context, [[self badgeTextColor] CGColor]);
163+
163164
NSMutableParagraphStyle *badgeTextStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
164165
[badgeTextStyle setLineBreakMode:NSLineBreakByWordWrapping];
165166
[badgeTextStyle setAlignment:NSTextAlignmentCenter];
@@ -174,18 +175,8 @@ - (void)drawRect:(CGRect)rect
174175
CGRectGetMinY(badgeBackgroundFrame) + kBadgeTextOffset,
175176
badgeSize.width, badgeSize.height)
176177
withAttributes:badgeTextAttributes];
177-
} else {
178-
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
179-
[[self badgeValue] drawInRect:CGRectMake(CGRectGetMinX(badgeBackgroundFrame) + kBadgeTextOffset,
180-
CGRectGetMinY(badgeBackgroundFrame) + kBadgeTextOffset,
181-
badgeSize.width, badgeSize.height)
182-
withFont:[self badgeTextFont]
183-
lineBreakMode:NSLineBreakByTruncatingTail
184-
alignment:NSTextAlignmentCenter];
185-
#endif
186178
}
187179
}
188-
189180
CGContextRestoreGState(context);
190181
}
191182

Coding_iOS/Util/OC_Category/NSString+Common.m

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -157,30 +157,11 @@ - (CGSize)getSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size{
157157
if (self.length <= 0) {
158158
return resultSize;
159159
}
160-
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
161-
resultSize = [self boundingRectWithSize:size
162-
options:(NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin)
163-
attributes:@{NSFontAttributeName: font}
164-
context:nil].size;
165-
} else {
166-
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
167-
resultSize = [self sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByWordWrapping];
168-
// NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:self attributes:@{NSFontAttributeName:font}];
169-
//
170-
// NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
171-
// [paragraphStyle setLineSpacing:2.0];
172-
//
173-
// [attributedStr addAttribute:NSParagraphStyleAttributeName
174-
// value:paragraphStyle
175-
// range:NSMakeRange(0, [self length])];
176-
// resultSize = [attributedStr boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin context:nil].size;
177-
178-
#endif
179-
}
160+
resultSize = [self boundingRectWithSize:size
161+
options:(NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin)
162+
attributes:@{NSFontAttributeName: font}
163+
context:nil].size;
180164
resultSize = CGSizeMake(MIN(size.width, ceilf(resultSize.width)), MIN(size.height, ceilf(resultSize.height)));
181-
// if ([self containsEmoji]) {
182-
// resultSize.height += 10;
183-
// }
184165
return resultSize;
185166
}
186167

0 commit comments

Comments
 (0)