├── .gitignore ├── BSYLoadingDemo.zip ├── BSYLoadingView.podspec ├── BSYLoadingView ├── BSYLoading.h ├── BSYLoading.m └── loading.png ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots/**/*.png 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /BSYLoadingDemo.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baishiyun/BSYLoadingView/b831dc4751bb68bf207c3d2858c5379a7f6ae0e3/BSYLoadingDemo.zip -------------------------------------------------------------------------------- /BSYLoadingView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "BSYLoadingView" 3 | s.version = "1.1.0" 4 | s.license = "MIT" 5 | s.summary = "BSYLoadingView 是一款自定义的UIActivityIndicatorView,开发者可以自定义 菊花颜色/背景颜色/文本信息/文本颜色/文本字体/文本对其方法等。是一款比较灵活好用的控件,如果对你有用,请给Star,谢谢" 6 | 7 | s.homepage = "https://github.com/baishiyun/BSYLoadingView" 8 | s.source = { :git => "https://github.com/baishiyun/BSYLoadingView.git", :tag => "#{s.version}" } 9 | s.source_files = "BSYLoadingView/*.{h,m,png}" 10 | s.requires_arc = true 11 | s.platform = :ios, "7.0" 12 | s.frameworks = "UIKit", "Foundation" 13 | s.author = { "白仕云" => "baishiyun@163.com" } 14 | s.social_media_url = "https://github.com/baishiyun" 15 | 16 | end -------------------------------------------------------------------------------- /BSYLoadingView/BSYLoading.h: -------------------------------------------------------------------------------- 1 | // 2 | // BSYLoading.h 3 | // BSYLoading 4 | // 5 | // Created by 白仕云 on 2018/5/17. 6 | // Copyright © 2018年 BSY.com. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface BSYLoading : NSObject 13 | 14 | // ############################################# 无文本信息 ################################### 15 | 16 | /** 17 | 隐藏菊花 18 | */ 19 | +(void)hidenCrazyCircleAnimation; 20 | 21 | /** 22 | 菊花 23 | */ 24 | +(void)showCrazyCircle; 25 | 26 | /** 27 | 菊花颜色自定义 28 | @param CircleColor 菊花颜色 29 | */ 30 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor; 31 | 32 | /** 33 | 菊花颜色自定义 背景颜色自定义 34 | @param BgColor 背景颜色 35 | @param CircleColor 菊花颜色 36 | */ 37 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor BgColor:(UIColor *)BgColor; 38 | 39 | // ############################################# 有文本信息 ################################### 40 | 41 | /** 42 | 文字和菊花 43 | @param text 文本信息 44 | */ 45 | +(void)showCrazyCircleWithText:(NSString *)text; 46 | 47 | 48 | /** 49 | 文字和菊花 50 | @param CircleColor 菊花颜色 51 | @param text 文本信息 52 | */ 53 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor Text:(NSString *)text; 54 | 55 | /** 56 | 文字和菊花 57 | @param CircleColor 菊花颜色 58 | @param text 文本信息 59 | @param TextColor 文本颜色 60 | */ 61 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor Text:(NSString *)text TextColor:(UIColor *)TextColor; 62 | 63 | 64 | /** 65 | 文字菊花效果 66 | @param CircleColor 菊花颜色 67 | @param BgColor 波浪背景颜色 68 | @param text 文本信息 69 | @param TextColor 文本颜色 70 | */ 71 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor BgColor:(UIColor *)BgColor Text:(NSString *)text TextColor:(UIColor *)TextColor; 72 | 73 | /** 74 | 文字和菊花 75 | @param CircleColor 菊花颜色 76 | @param BgColor 波浪背景颜色 77 | @param text 文本信息 78 | @param TextColor 文本颜色 79 | @param TextFont 文本字体 80 | */ 81 | 82 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor BgColor:(UIColor *)BgColor Text:(NSString *)text TextColor:(UIColor *)TextColor TextFont:(CGFloat)TextFont; 83 | 84 | /** 85 | 文字和菊花 86 | @param CircleColor 菊花颜色 87 | @param BgColor 波浪背景颜色 88 | @param text 文本信息 89 | @param TextColor 文本颜色 90 | @param TextFont 文本字体 91 | @param TextAlignment 文本对其方法 92 | */ 93 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor BgColor:(UIColor *)BgColor Text:(NSString *)text TextColor:(UIColor *)TextColor TextFont:(CGFloat)TextFont TextAlignment:(NSTextAlignment)TextAlignment; 94 | @end 95 | -------------------------------------------------------------------------------- /BSYLoadingView/BSYLoading.m: -------------------------------------------------------------------------------- 1 | // 2 | // BSYLoading.m 3 | // BSYLoading 4 | // 5 | // Created by 白仕云 on 2018/5/17. 6 | // Copyright © 2018年 BSY.com. All rights reserved. 7 | // 8 | 9 | // 默认菊花颜色 10 | #define DefalutCrazyCircleColor [UIColor whiteColor] 11 | // 默认菊花背景颜色 12 | #define DefalutCrazyCircleBgColor [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6] 13 | 14 | // 文本默认颜色 15 | #define DefalutTextTextColor [UIColor blackColor] 16 | // 文本默认对齐方式 17 | #define DefalutTextTextAlignment NSTextAlignmentCenter 18 | // 文本默认字体大小 19 | #define DefalutTextTextFont 17.00 20 | // 获取最后一个有效Window 21 | #define MainWindow [UIApplication sharedApplication].windows.lastObject 22 | 23 | //默认背景宽度 24 | #define DefalutBGWith 150 25 | 26 | #define bgViewTag 99999999999999 27 | #import "BSYLoading.h" 28 | 29 | @interface BSYLoading() 30 | @end 31 | @implementation BSYLoading 32 | 33 | /** 34 | 菊花 35 | */ 36 | +(void)showCrazyCircle 37 | { 38 | 39 | 40 | if ([self have]==true) { 41 | return; 42 | } 43 | UIImageView *loading = [self returnCrazyCircleLoadingView]; 44 | loading.frame = CGRectMake(50, 0, 50, 50); 45 | UIView *bgView = [self returnBgView]; 46 | [bgView addSubview:loading]; 47 | [self setAnimationWithloadingImage:loading]; 48 | } 49 | 50 | /** 51 | 菊花颜色自定义 52 | @param CircleColor 菊花颜色 53 | */ 54 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor 55 | { 56 | 57 | if ([self have]==true) { 58 | return; 59 | } 60 | CircleColor =CircleColor?CircleColor:DefalutCrazyCircleColor; 61 | UIImageView *loading = [self returnCrazyCircleLoadingView]; 62 | loading.frame = CGRectMake(50, 0, 50, 50); 63 | loading.image = [self imageWithColor:CircleColor Image:loading.image]; 64 | UIView *bgView = [self returnBgView]; 65 | [bgView addSubview:loading]; 66 | [self setAnimationWithloadingImage:loading]; 67 | } 68 | 69 | /** 70 | 菊花颜色自定义 背景颜色自定义 71 | @param BgColor 背景颜色 72 | @param CircleColor 菊花颜色 73 | */ 74 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor BgColor:(UIColor *)BgColor 75 | { 76 | 77 | if ([self have]==true) { 78 | return; 79 | } 80 | CircleColor =CircleColor?CircleColor:DefalutCrazyCircleColor; 81 | BgColor =BgColor?BgColor:DefalutCrazyCircleBgColor; 82 | UIImageView *loading = [self returnCrazyCircleLoadingView]; 83 | loading.image = [self imageWithColor:CircleColor Image:loading.image]; 84 | loading.frame = CGRectMake(50, 0, 50, 50); 85 | UIView *bgView = [self returnBgView]; 86 | bgView.backgroundColor = BgColor; 87 | [bgView addSubview:loading]; 88 | [self setAnimationWithloadingImage:loading]; 89 | 90 | } 91 | 92 | // ############################################# 有文本信息 ################################### 93 | 94 | /** 95 | 文字和菊花 96 | @param text 文本信息 97 | */ 98 | +(void)showCrazyCircleWithText:(NSString *)text 99 | 100 | { 101 | 102 | if ([self have]==true) { 103 | return; 104 | } 105 | text =text?([text isEqualToString:@""]?@"加载中···":text):@"加载中···"; 106 | 107 | //菊花 108 | UIImageView *loading = [self returnCrazyCircleLoadingView]; 109 | //文本 110 | UILabel *Text =[self returnTextString]; 111 | Text.text = text; 112 | UIView *bgView = [self returnBgView]; 113 | 114 | //计算文本宽度,更新背景/Lable宽度 115 | CGFloat With = [self widthForString:text fontSize:DefalutTextTextFont]; 116 | if (With>DefalutBGWith){ 117 | bgView.frame = CGRectMake((MainWindow.bounds.size.width-With)/2.0, (MainWindow.bounds.size.height-50)/2.0, With, 50); 118 | Text.frame =CGRectMake(50, 0, With-50, 50); 119 | } 120 | 121 | [bgView addSubview:Text]; 122 | [bgView addSubview:loading]; 123 | //动画 124 | [self setAnimationWithloadingImage:loading]; 125 | 126 | } 127 | 128 | /** 129 | 文字和菊花 130 | @param CircleColor 菊花颜色 131 | @param text 文本信息 132 | */ 133 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor Text:(NSString *)text 134 | { 135 | if ([self have]==true) { 136 | return; 137 | } 138 | 139 | CircleColor =CircleColor?CircleColor:DefalutCrazyCircleColor; 140 | text =text?([text isEqualToString:@""]?@"加载中···":text):@"加载中···"; 141 | //菊花 142 | UIImageView *loading = [self returnCrazyCircleLoadingView]; 143 | loading.image = [self imageWithColor:CircleColor Image:loading.image]; 144 | //文本 145 | UILabel *Text =[self returnTextString]; 146 | Text.text = text; 147 | UIView *bgView = [self returnBgView]; 148 | 149 | //计算文本宽度,更新背景/Lable宽度 150 | CGFloat With = [self widthForString:text fontSize:DefalutTextTextFont]; 151 | if (With>DefalutBGWith){ 152 | bgView.frame = CGRectMake((MainWindow.bounds.size.width-With)/2.0, (MainWindow.bounds.size.height-50)/2.0, With, 50); 153 | Text.frame =CGRectMake(50, 0, With-50, 50); 154 | } 155 | [bgView addSubview:Text]; 156 | [bgView addSubview:loading]; 157 | //动画 158 | [self setAnimationWithloadingImage:loading]; 159 | 160 | } 161 | /** 162 | 文字和菊花 163 | @param CircleColor 菊花颜色 164 | @param text 文本信息 165 | @param TextColor 文本颜色 166 | */ 167 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor Text:(NSString *)text TextColor:(UIColor *)TextColor 168 | { 169 | 170 | 171 | NSLog(@" %d",[self have]); 172 | if ([self have]==true) { 173 | return; 174 | } 175 | text =text?([text isEqualToString:@""]?@"加载中···":text):@"加载中···"; 176 | CircleColor =CircleColor?CircleColor:DefalutCrazyCircleColor; 177 | TextColor = TextColor?TextColor:DefalutTextTextColor; 178 | //菊花 179 | UIImageView *loading = [self returnCrazyCircleLoadingView]; 180 | loading.image = [self imageWithColor:CircleColor Image:loading.image]; 181 | //文本 182 | UILabel *Text =[self returnTextString]; 183 | Text.textColor = TextColor; 184 | Text.text = text; 185 | UIView *bgView = [self returnBgView]; 186 | 187 | //计算文本宽度,更新背景/Lable宽度 188 | CGFloat With = [self widthForString:text fontSize:DefalutTextTextFont]; 189 | if (With>DefalutBGWith){ 190 | bgView.frame = CGRectMake((MainWindow.bounds.size.width-With)/2.0, (MainWindow.bounds.size.height-50)/2.0, With, 50); 191 | Text.frame =CGRectMake(50, 0, With-50, 50); 192 | } 193 | [bgView addSubview:Text]; 194 | [bgView addSubview:loading]; 195 | //动画 196 | [self setAnimationWithloadingImage:loading]; 197 | 198 | } 199 | 200 | /** 201 | 文字菊花效果 202 | @param CircleColor 菊花颜色 203 | @param BgColor 波浪背景颜色 204 | @param text 文本信息 205 | @param TextColor 文本颜色 206 | */ 207 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor BgColor:(UIColor *)BgColor Text:(NSString *)text TextColor:(UIColor *)TextColor 208 | { 209 | 210 | if ([self have]==true) { 211 | return; 212 | } 213 | text =text?([text isEqualToString:@""]?@"加载中···":text):@"加载中···"; 214 | CircleColor =CircleColor?CircleColor:DefalutCrazyCircleColor; 215 | BgColor =BgColor?BgColor:DefalutCrazyCircleBgColor; 216 | TextColor = TextColor?TextColor:DefalutTextTextColor; 217 | //菊花 218 | UIImageView *loading = [self returnCrazyCircleLoadingView]; 219 | loading.image = [self imageWithColor:CircleColor Image:loading.image]; 220 | //文本 221 | UILabel *Text =[self returnTextString]; 222 | Text.textColor = TextColor; 223 | Text.text = text; 224 | UIView *bgView = [self returnBgView]; 225 | bgView.backgroundColor = BgColor; 226 | 227 | //计算文本宽度,更新背景/Lable宽度 228 | CGFloat With = [self widthForString:text fontSize:DefalutTextTextFont]; 229 | if (With>DefalutBGWith){ 230 | bgView.frame = CGRectMake((MainWindow.bounds.size.width-With)/2.0, (MainWindow.bounds.size.height-50)/2.0, With, 50); 231 | Text.frame =CGRectMake(50, 0, With-50, 50); 232 | } 233 | [bgView addSubview:Text]; 234 | [bgView addSubview:loading]; 235 | //动画 236 | [self setAnimationWithloadingImage:loading]; 237 | 238 | } 239 | 240 | /** 241 | 文字和菊花 242 | @param CircleColor 菊花颜色 243 | @param BgColor 波浪背景颜色 244 | @param text 文本信息 245 | @param TextColor 文本颜色 246 | @param TextFont 文本字体 247 | */ 248 | 249 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor BgColor:(UIColor *)BgColor Text:(NSString *)text TextColor:(UIColor *)TextColor TextFont:(CGFloat)TextFont 250 | { 251 | 252 | if ([self have]==true) { 253 | return; 254 | } 255 | text =text?([text isEqualToString:@""]?@"加载中···":text):@"加载中···"; 256 | CircleColor =CircleColor?CircleColor:DefalutCrazyCircleColor; 257 | BgColor =BgColor?BgColor:DefalutCrazyCircleBgColor; 258 | TextColor = TextColor?TextColor:DefalutTextTextColor; 259 | TextFont = TextFont?TextFont:(CGFloat)DefalutTextTextFont; 260 | 261 | //菊花 262 | UIImageView *loading = [self returnCrazyCircleLoadingView]; 263 | loading.image = [self imageWithColor:CircleColor Image:loading.image]; 264 | //文本 265 | UILabel *Text =[self returnTextString]; 266 | Text.textColor = TextColor; 267 | Text.text = text; 268 | Text.font =[UIFont systemFontOfSize:TextFont]; 269 | 270 | UIView *bgView = [self returnBgView]; 271 | bgView.backgroundColor = BgColor; 272 | 273 | //计算文本宽度,更新背景/Lable宽度 274 | CGFloat With = [self widthForString:text fontSize:DefalutTextTextFont]; 275 | if (With>DefalutBGWith){ 276 | bgView.frame = CGRectMake((MainWindow.bounds.size.width-With)/2.0, (MainWindow.bounds.size.height-50)/2.0, With, 50); 277 | Text.frame =CGRectMake(50, 0, With-50, 50); 278 | } 279 | [bgView addSubview:Text]; 280 | [bgView addSubview:loading]; 281 | //动画 282 | [self setAnimationWithloadingImage:loading]; 283 | } 284 | 285 | /** 286 | 文字和菊花 287 | @param CircleColor 菊花颜色 288 | @param BgColor 背景颜色 289 | @param text 文本信息 290 | @param TextColor 文本颜色 291 | @param TextFont 文本字体 292 | @param TextAlignment 文本对其方法 293 | */ 294 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor BgColor:(UIColor *)BgColor Text:(NSString *)text TextColor:(UIColor *)TextColor TextFont:(CGFloat)TextFont TextAlignment:(NSTextAlignment)TextAlignment 295 | { 296 | 297 | if ([self have]==true) { 298 | return; 299 | } 300 | text =text?([text isEqualToString:@""]?@"加载中···":text):@"加载中···"; 301 | CircleColor =CircleColor?CircleColor:DefalutCrazyCircleColor; 302 | BgColor = BgColor?BgColor:DefalutCrazyCircleBgColor; 303 | TextColor = TextColor?TextColor:DefalutTextTextColor; 304 | TextFont = TextFont?TextFont:(CGFloat)DefalutTextTextFont; 305 | TextAlignment = TextAlignment?TextAlignment:DefalutTextTextAlignment; 306 | 307 | //菊花 308 | UIImageView *loading = [self returnCrazyCircleLoadingView]; 309 | loading.image = [self imageWithColor:CircleColor Image:loading.image]; 310 | 311 | //文本 312 | UILabel *Text =[self returnTextString]; 313 | Text.textColor = TextColor; 314 | Text.text = text; 315 | Text.font =[UIFont systemFontOfSize:TextFont]; 316 | Text.textAlignment = TextAlignment; 317 | UIView *bgView = [self returnBgView]; 318 | bgView.backgroundColor = BgColor; 319 | 320 | //计算文本宽度,更新背景/Lable宽度 321 | CGFloat With = [self widthForString:text fontSize:DefalutTextTextFont]; 322 | if (With>DefalutBGWith){ 323 | bgView.frame = CGRectMake((MainWindow.bounds.size.width-With)/2.0, (MainWindow.bounds.size.height-50)/2.0, With, 50); 324 | Text.frame =CGRectMake(50, 0, With-50, 50); 325 | } 326 | [bgView addSubview:Text]; 327 | [bgView addSubview:loading]; 328 | //动画 329 | [self setAnimationWithloadingImage:loading]; 330 | 331 | } 332 | /** 333 | 判断菊花是不是已经存在 334 | @return true是存在。False是不存在 335 | */ 336 | +(BOOL)have 337 | { 338 | BOOL haveBool = false; 339 | for (UIView *bgView in MainWindow.subviews) { 340 | if (bgView.tag==bgViewTag) { 341 | haveBool = true; 342 | } 343 | } 344 | return haveBool; 345 | } 346 | 347 | /** 348 | 隐藏菊花 349 | */ 350 | +(void)hidenCrazyCircleAnimation 351 | { 352 | for (UIView *bgView in MainWindow.subviews) { 353 | if (bgView.tag==bgViewTag) { 354 | [UIView animateWithDuration:0.5 animations:^{ 355 | bgView.alpha = 0; 356 | } completion:^(BOOL finished) { 357 | bgView.alpha = 0; 358 | [bgView removeFromSuperview]; 359 | }]; 360 | } 361 | } 362 | } 363 | 364 | /** 365 | * 重新绘制图片 366 | * 367 | * @param color 填充色 368 | * 369 | * @return UIImage 370 | */ 371 | +(UIImage *)imageWithColor:(UIColor *)color Image:(UIImage *)image 372 | { 373 | UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale); 374 | CGContextRef context = UIGraphicsGetCurrentContext(); 375 | CGContextTranslateCTM(context, 0, image.size.height); 376 | CGContextScaleCTM(context, 1.0, -1.0); 377 | CGContextSetBlendMode(context, kCGBlendModeNormal); 378 | CGRect rect = CGRectMake(0, 0, 50, 50); 379 | CGContextClipToMask(context, rect, image.CGImage); 380 | [color setFill]; 381 | CGContextFillRect(context, rect); 382 | UIImage*newImage = UIGraphicsGetImageFromCurrentImageContext(); 383 | UIGraphicsEndImageContext(); 384 | return newImage; 385 | } 386 | 387 | /** 388 | 菊花动画 389 | */ 390 | +(void)setAnimationWithloadingImage:(UIImageView *)loading 391 | { 392 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; 393 | // 1秒后执行 394 | animation.beginTime = 0.1; 395 | // 重复次数 396 | animation.repeatCount = MAXFLOAT; 397 | // 起始角度 398 | animation.fromValue = @(0.0); 399 | // 终止角度 400 | animation.toValue = @(MAXFLOAT); 401 | // 添加动画 402 | [loading.layer addAnimation:animation forKey:@"rotate"]; 403 | } 404 | 405 | /** 406 | 创建 CrazyCircle 407 | @return 返回创建的View 408 | */ 409 | +(UIImageView *)returnCrazyCircleLoadingView 410 | { 411 | UIImageView *loading = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 50, 50)]; 412 | loading.backgroundColor = [UIColor clearColor]; 413 | loading.image = [UIImage imageNamed:@"loading.png"]; 414 | loading.layer.borderWidth =1; 415 | loading.layer.borderColor = [UIColor clearColor].CGColor; 416 | loading.layer.cornerRadius = 25; 417 | return loading; 418 | } 419 | 420 | /** 421 | 创建背景View 422 | @return 返回创建的View 423 | */ 424 | +(UIView *)returnBgView 425 | { 426 | UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake((MainWindow.bounds.size.width-DefalutBGWith)/2.0, (MainWindow.bounds.size.height-50)/2.0, DefalutBGWith, 50)]; 427 | bgView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6]; 428 | [MainWindow addSubview:bgView]; 429 | bgView.layer.borderWidth =1; 430 | bgView.layer.borderColor = [UIColor clearColor].CGColor; 431 | bgView.layer.cornerRadius = 5; 432 | bgView.tag =bgViewTag; 433 | return bgView; 434 | } 435 | 436 | /** 437 | 创建Text 438 | @return 返回创建的View 439 | */ 440 | +(UILabel *)returnTextString 441 | { 442 | UILabel *bgView = [[UILabel alloc]initWithFrame:CGRectMake(50, 0, 100, 50)]; 443 | bgView.textColor =[UIColor whiteColor]; 444 | bgView.font = [UIFont systemFontOfSize:DefalutTextTextFont]; 445 | bgView.textAlignment = DefalutTextTextAlignment; 446 | return bgView; 447 | } 448 | 449 | 450 | /** 451 | 计算文本宽度 452 | 453 | @param value 字符串 454 | @param fontSize 文本大小 455 | @return 返回文本宽度 456 | */ 457 | +(CGFloat)widthForString:(NSString *)value fontSize:(CGFloat)fontSize 458 | { 459 | CGSize size = [value sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:fontSize]}]; 460 | //获取宽高 461 | CGSize statuseStrSize = CGSizeMake(ceilf(size.width), ceilf(size.height)); 462 | if (statuseStrSize.width>=MainWindow.bounds.size.width) { 463 | statuseStrSize.width =MainWindow.bounds.size.width-20; 464 | } 465 | return statuseStrSize.width; 466 | } 467 | @end 468 | -------------------------------------------------------------------------------- /BSYLoadingView/loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baishiyun/BSYLoadingView/b831dc4751bb68bf207c3d2858c5379a7f6ae0e3/BSYLoadingView/loading.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 白仕云 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BSYLoadingView 2 | BSYLoading 是一款自定义的UIActivityIndicatorView,开发者可以自定义 菊花颜色/背景颜色/文本信息/文本颜色/文本字体/文本对其方法等。是一款比较灵活好用的控件,现在已经支持cocoapods安装,如果对你有用,请给Star,谢谢 3 | 4 | // ############# 无文本信息 ############### 5 | 6 | /** 7 | 8 | 隐藏菊花 9 | 10 | */ 11 | 12 | +(void)hidenCrazyCircleAnimation; 13 | 14 | /** 15 | 16 | 菊花 17 | 18 | */ 19 | 20 | +(void)showCrazyCircle; 21 | 22 | /** 23 | 24 | 菊花颜色自定义 25 | 26 | @param CircleColor 菊花颜色 27 | 28 | */ 29 | 30 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor; 31 | 32 | /** 33 | 34 | 菊花颜色自定义 背景颜色自定义 35 | 36 | @param BgColor 背景颜色 37 | 38 | @param CircleColor 菊花颜色 39 | 40 | */ 41 | 42 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor BgColor:(UIColor *)BgColor; 43 | 44 | 45 | // ############ 有文本信息 ################## 46 | 47 | /** 48 | 49 | 文字和菊花 50 | 51 | @param text 文本信息 52 | 53 | */ 54 | 55 | +(void)showCrazyCircleWithText:(NSString *)text; 56 | 57 | /** 58 | 59 | 文字和菊花 60 | 61 | @param CircleColor 菊花颜色 62 | 63 | @param text 文本信息 64 | 65 | */ 66 | 67 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor Text:(NSString *)text; 68 | 69 | /** 70 | 71 | 文字和菊花 72 | 73 | @param CircleColor 菊花颜色 74 | 75 | @param text 文本信息 76 | 77 | @param TextColor 文本颜色 78 | 79 | */ 80 | 81 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor Text:(NSString *)text TextColor:(UIColor *)TextColor; 82 | 83 | 84 | /** 85 | 86 | 文字菊花效果 87 | 88 | @param CircleColor 菊花颜色 89 | 90 | @param BgColor 背景颜色 91 | 92 | @param text 文本信息 93 | 94 | @param TextColor 文本颜色 95 | 96 | */ 97 | 98 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor BgColor:(UIColor *)BgColor Text:(NSString *)text TextColor:(UIColor *)TextColor; 99 | 100 | /** 101 | 102 | 文字和菊花 103 | 104 | @param CircleColor 菊花颜色 105 | 106 | @param BgColor 背景颜色 107 | 108 | @param text 文本信息 109 | 110 | @param TextColor 文本颜色 111 | 112 | @param TextFont 文本字体 113 | 114 | */ 115 | 116 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor BgColor:(UIColor *)BgColor Text:(NSString *)text TextColor:(UIColor *)TextColor TextFont:(UIFont *)TextFont; 117 | 118 | /** 119 | 120 | 文字和菊花 121 | 122 | @param CircleColor 菊花颜色 123 | 124 | @param BgColor 背景颜色 125 | 126 | @param text 文本信息 127 | 128 | @param TextColor 文本颜色 129 | 130 | @param TextFont 文本字体 131 | 132 | @param TextAlignment 文本对其方法 133 | 134 | */ 135 | 136 | +(void)showCrazyCircleWithColor:(UIColor *)CircleColor BgColor:(UIColor *)BgColor Text:(NSString *)text TextColor:(UIColor *)TextColor TextFont:(UIFont *)TextFont TextAlignment:(NSTextAlignment)TextAlignment; 137 | --------------------------------------------------------------------------------