Skip to content

Commit 961242a

Browse files
committed
调整了部分注释
1 parent 66a7573 commit 961242a

5 files changed

Lines changed: 104 additions & 13 deletions

File tree

Demo/SJAttributesFactory.xcworkspace/xcuserdata/bluedancer.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,67 @@
44
version = "2.0">
55
<Breakpoints>
66
<BreakpointProxy
7-
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
7+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
88
<BreakpointContent
99
shouldBeEnabled = "Yes"
1010
ignoreCount = "0"
1111
continueAfterRunningActions = "No"
12-
scope = "0"
13-
stopOnStyle = "0">
12+
filePath = "../SJAttributesFactory/SJAttributeWorker.m"
13+
timestampString = "545030336.722531"
14+
startingColumnNumber = "9223372036854775807"
15+
endingColumnNumber = "9223372036854775807"
16+
startingLineNumber = "352"
17+
endingLineNumber = "352"
18+
landmarkName = "-_adjustOperatorsWhenInsertingText:"
19+
landmarkType = "7">
20+
</BreakpointContent>
21+
</BreakpointProxy>
22+
<BreakpointProxy
23+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
24+
<BreakpointContent
25+
shouldBeEnabled = "Yes"
26+
ignoreCount = "0"
27+
continueAfterRunningActions = "No"
28+
filePath = "../SJAttributesFactory/SJAttributeWorker.m"
29+
timestampString = "545030336.722855"
30+
startingColumnNumber = "9223372036854775807"
31+
endingColumnNumber = "9223372036854775807"
32+
startingLineNumber = "344"
33+
endingLineNumber = "344"
34+
landmarkName = "-_adjustOperatorsWhenInsertingText:"
35+
landmarkType = "7">
36+
</BreakpointContent>
37+
</BreakpointProxy>
38+
<BreakpointProxy
39+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
40+
<BreakpointContent
41+
shouldBeEnabled = "Yes"
42+
ignoreCount = "0"
43+
continueAfterRunningActions = "No"
44+
filePath = "../SJAttributesFactory/SJAttributeWorker.m"
45+
timestampString = "545030336.722917"
46+
startingColumnNumber = "9223372036854775807"
47+
endingColumnNumber = "9223372036854775807"
48+
startingLineNumber = "328"
49+
endingLineNumber = "328"
50+
landmarkName = "-_adjustOperatorsWhenInsertingText:"
51+
landmarkType = "7">
52+
</BreakpointContent>
53+
</BreakpointProxy>
54+
<BreakpointProxy
55+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
56+
<BreakpointContent
57+
shouldBeEnabled = "Yes"
58+
ignoreCount = "0"
59+
continueAfterRunningActions = "No"
60+
filePath = "../SJAttributesFactory/SJAttributeWorker.m"
61+
timestampString = "545030336.72297"
62+
startingColumnNumber = "9223372036854775807"
63+
endingColumnNumber = "9223372036854775807"
64+
startingLineNumber = "312"
65+
endingLineNumber = "312"
66+
landmarkName = "-_adjustOperatorsWhenInsertingText:"
67+
landmarkType = "7">
1468
</BreakpointContent>
1569
</BreakpointProxy>
1670
</Breakpoints>

Demo/SJAttributesFactory/ViewController.m

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,33 +43,38 @@ - (void)_setupViews {
4343
[self.tableView registerClass:NSClassFromString(UITableViewCellID) forCellReuseIdentifier:UITableViewCellID];
4444
self.tableView.delegate = self;
4545
self.tableView.dataSource = self;
46+
47+
4648

4749
}
4850

4951
#pragma mark -
5052
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
53+
5154
NSAttributedString *attr = nil;
5255
NSString *tips = nil;
5356
switch (indexPath.row) {
5457
case 0: {
5558
tips = @"常用方法";
5659
attr = sj_makeAttributesString(^(SJAttributeWorker * _Nonnull make) {
5760
make.insert(@"叶秋笑了笑,抬手取下了衔在嘴角的烟头。", 0);
58-
61+
5962
make
6063
.font([UIFont boldSystemFontOfSize:40]) // 设置字体
6164
.textColor([UIColor blackColor]) // 设置文本颜色
6265
.underLine(NSUnderlineStyleSingle, [UIColor orangeColor]) // 设置下划线
6366
.strikethrough(NSUnderlineStyleSingle, [UIColor orangeColor]) // 设置删除线
6467
// .shadow(CGSizeMake(0.5, 0.5), 0, [UIColor redColor]) // 设置阴影
6568
// .backgroundColor([UIColor whiteColor]) // 设置文本背景颜色
66-
.stroke([UIColor greenColor], 1) // 字体边缘的颜色, 设置后, 字体会镂空
69+
// .stroke([UIColor greenColor], 1) // 字体边缘的颜色, 设置后, 字体会镂空
6770
// .offset(-10) // 上下偏移
6871
.obliqueness(0.3) // 倾斜
6972
.letterSpacing(4) // 字体间隔
7073
.lineSpacing(4) // 行间隔
7174
.alignment(NSTextAlignmentCenter) // 对其方式
7275
;
76+
77+
make.append(@"Hello").font([UIFont systemFontOfSize:22]).textColor([UIColor redColor]);
7378
[self updateConstraintsWithSize:make.sizeByWidth(self.view.bounds.size.width - 80)];
7479
});
7580
}
@@ -192,16 +197,45 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
192197
make.append(@"Hello").font([UIFont systemFontOfSize:14]).textColor([UIColor yellowColor]);
193198
make.append([UIImage imageNamed:@"sample2"], CGPointZero, CGSizeZero);
194199

200+
201+
make.append(@"hhHHh");
202+
// 忽略大小写
203+
make.regexpOptions = NSRegularExpressionCaseInsensitive;
204+
make.regexp(@"H", ^(SJAttributesRangeOperator * _Nonnull make) {
205+
make.textColor([UIColor purpleColor]);
206+
});
207+
195208
[self updateConstraintsWithSize:make.sizeByWidth(self.view.bounds.size.width - 80)];
196209
});
197210
}
211+
break;
212+
case 7: {
213+
tips = @"测试";
214+
215+
attr = sj_makeAttributesString(^(SJAttributeWorker * _Nonnull make) {
216+
make.font([UIFont systemFontOfSize:14]).textColor([UIColor blackColor]);
217+
make.append(@"@迷你世界联机 :@江叔 用小淘气耍赖野人#迷你世界#");
218+
219+
make.regexp(@"@\\w+", ^(SJAttributesRangeOperator * _Nonnull make) {
220+
make.textColor([UIColor purpleColor]);
221+
});
222+
223+
make.regexp(@"#[^#]+#", ^(SJAttributesRangeOperator * _Nonnull make) {
224+
make.textColor([UIColor orangeColor]);
225+
});
226+
227+
228+
[self updateConstraintsWithSize:make.sizeByWidth(self.view.bounds.size.width - 80)];
229+
});
230+
}
231+
break;
198232
}
199233

200234

201235
if ( !attr ) return;
202236
_tipsLabel.text = tips;
203237
_testLabel.attributedText = attr;
204-
238+
205239
NSLog(@"------------- end -------------");
206240
}
207241

SJAttributesFactory.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
#
1717

1818
s.name = "SJAttributesFactory"
19-
s.version = "2.0.3.1"
19+
s.version = "2.0.3.2"
2020
s.summary = "富文本编辑工厂."
2121

2222
# This description is used to generate tags and improve search results.

SJAttributesFactory/SJAttributeWorker.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
2424
* // set font , text color.
2525
* make.font([UIFont boldSystemFontOfSize:14]).textColor([UIColor blackColor]);
2626
27-
* // inset text
28-
* make.insert(@"@迷你世界联机 :@江叔 用小淘气耍赖野人#迷你世界#", 0);
27+
* make.append(@"@迷你世界联机 :@江叔 用小淘气耍赖野人#迷你世界#");
2928
3029
* make.regexp(@"[@][^@]+\\s", ^(SJAttributesRangeOperator * _Nonnull matched) {
3130
* matched.textColor([UIColor purpleColor]);
@@ -124,7 +123,8 @@ extern NSMutableAttributedString *sj_makeAttributesString(void(^block)(SJAttribu
124123
NSRange matchedRange = [obj rangeValue];
125124
126125
make.replace(matchedRange, @"h");
127-
make.insert(@"ello", matchedRange.location + matchedRange.length); // h + ello == hello
126+
NSInteger index = matchedRange.location + matchedRange.length;
127+
make.insert(@"ello", index); // h + ello == hello
128128
}];
129129
}, YES);
130130
**/
@@ -133,7 +133,7 @@ extern NSMutableAttributedString *sj_makeAttributesString(void(^block)(SJAttribu
133133

134134
/**
135135
make.regexp_replace(@"Hello", @" World!");
136-
make.regexp_replace(@"Hello", [UIImage imageNamed:@"sample2"], CGPointMake(0, 0), CGSizeZero);
136+
make.regexp_replace(@"Hello", [UIImage imageNamed:@"sample2"], CGPointZero, CGSizeZero);
137137
*/
138138
@property (nonatomic, copy, readonly) void(^regexp_replace)(NSString *regexp, id replaceByStrOrAttrStrOrImg, ...);
139139

@@ -144,7 +144,7 @@ typedef NS_ENUM(NSUInteger, SJAttributeRegexpInsertPosition) {
144144
};
145145
/**
146146
make.regexp_insert(@"Hello", SJAttributeRegexpInsertPositionRight, @" World!");
147-
make.regexp_insert(@"Hello", SJAttributeRegexpInsertPositionRight, [UIImage imageNamed:@"sample2"], CGPointMake(0, 0), CGSizeZero);
147+
make.regexp_insert(@"Hello", SJAttributeRegexpInsertPositionRight, [UIImage imageNamed:@"sample2"], CGPointZero, CGSizeZero);
148148
*/
149149
@property (nonatomic, copy, readonly) void(^regexp_insert)(NSString *regexp, SJAttributeRegexpInsertPosition position, id insertingStrOrAttrStrOrImg, ...);
150150

@@ -167,7 +167,7 @@ typedef NS_ENUM(NSUInteger, SJAttributeRegexpInsertPosition) {
167167
#pragma mark - 插入 - insert
168168
@interface SJAttributeWorker(Insert)
169169

170-
#pragma mark - often
170+
#pragma mark - 常用方法
171171

172172
/**
173173
append text.
@@ -177,6 +177,9 @@ typedef NS_ENUM(NSUInteger, SJAttributeRegexpInsertPosition) {
177177
*/
178178
@property (nonatomic, copy, readonly) SJAttributesRangeOperator *(^append)(id strOrImg, ...);
179179

180+
181+
182+
180183
#pragma mark -
181184
/*!
182185
* the range of the last inserted text.

0 commit comments

Comments
 (0)