-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewController.m
More file actions
42 lines (33 loc) · 1.19 KB
/
Copy pathViewController.m
File metadata and controls
42 lines (33 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// ViewController.m
// ClassificationDemo
//
// Created by 袁涛 on 2017/11/25.
// Copyright © 2017年 Y_T. All rights reserved.
//
#import "ViewController.h"
#import "UIButton+UIExtension.h"
#import "NSObject+UIExtension.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *label = [[UILabel alloc] init];
label.text = @"11111wodddai我爱111111111wo1ai我爱你";
label.frame = CGRectMake(0, 100, [UIScreen mainScreen].bounds.size.width, 20);
NSArray <NSString *>*arr = [NSObject RegularText:label.text pattern:@"我爱"];
NSMutableAttributedString *att = [[NSMutableAttributedString alloc] initWithString:label.text];
for (NSString *rangStr in arr) {
NSRange range = NSRangeFromString(rangStr);
[att addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:27] range:range];
[att addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:range];
}
label.attributedText = att;
[self.view addSubview:label];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end