This commit is contained in:
2025-08-20 09:08:28 +08:00
parent 59b42526b5
commit 7787b3ee30
28 changed files with 253 additions and 61 deletions

View File

@@ -81,25 +81,26 @@ static NSString *identifier = @"AvatarCollectionViewCell";
if (ISNULLSTR(link.icon)) {
cell.avatarImageView.image = [self circularImageWithText:link.name];
}else{
NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:link.icon] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"Error downloading image: %@", error);
} else {
dispatch_async(dispatch_get_main_queue(), ^{
UIImage *image = [UIImage imageWithData:data];
cell.avatarImageView.image = image;
});
}
}];
[dataTask resume];
cell.avatarImageView.image = [UIImage imageNamed:link.icon];
// NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:link.icon] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
// if (error) {
// NSLog(@"Error downloading image: %@", error);
// } else {
// dispatch_async(dispatch_get_main_queue(), ^{
// UIImage *image = [UIImage imageWithData:data];
// cell.avatarImageView.image = image;
// });
// }
// }];
// [dataTask resume];
}
}else if ([value isKindOfClass:[NSNumber class]]) {
NSNumber *number = value;
DSWebMenuType type = number.integerValue;
if (type == DSWebMenuHomeType) {
cell.avatarImageView.image = [UIImage imageNamed:@"menu"];
cell.avatarImageView.image = [UIImage imageNamed:@"menu2"];
}else if (type == DSWebMenuRefreshType) {
cell.avatarImageView.image = [UIImage imageNamed:@"refresh"];
cell.avatarImageView.image = [UIImage imageNamed:@"refresh2"];
}else if (type == DSWebMenuTelegramType) {
cell.avatarImageView.image = [UIImage imageNamed:@"telegram"];
}else if (type == DSWebMenuWhatsAppType) {
@@ -107,10 +108,10 @@ static NSString *identifier = @"AvatarCollectionViewCell";
}else if (type == DSWebMenuFacebookType) {
cell.avatarImageView.image = [UIImage imageNamed:@"facebook"];
}else if (type == DSWebMenuNotiType) {
cell.avatarImageView.image = [UIImage imageNamed:@"noti"];
cell.imgWidth.constant = 40;
cell.avatarImageView.layer.cornerRadius = 20.f;
cell.avatarImageView.layer.masksToBounds = YES;
cell.avatarImageView.image = [UIImage imageNamed:@"noti2"];
// cell.imgWidth.constant = 40;
// cell.avatarImageView.layer.cornerRadius = 20.f;
// cell.avatarImageView.layer.masksToBounds = YES;
}
}
cell.avatarImageView.contentMode = UIViewContentModeScaleAspectFit;
@@ -127,7 +128,7 @@ static NSString *identifier = @"AvatarCollectionViewCell";
- (UIImage *)circularImageWithText:(NSString *)text {
//
UIFont *font = [UIFont systemFontOfSize:16.0f];
UIFont *font = [UIFont boldSystemFontOfSize:15.0f];
CGSize textSize = [text sizeWithFont:font];
//
@@ -141,11 +142,11 @@ static NSString *identifier = @"AvatarCollectionViewCell";
CGContextClip(context);
//
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0); //
CGContextSetRGBFillColor(context, 228.0/255.0, 171.0/255.0, 95.0/255.0, 1.0); //
CGContextFillRect(context, rect);
//
[[UIColor redColor] set];
[[UIColor blackColor] set];
// 使
CGFloat x = (size - textSize.width) / 2.0f;