ibireme / yykit Goto Github PK
View Code? Open in Web Editor NEWA collection of iOS components.
License: MIT License
A collection of iOS components.
License: MIT License
如果动态图本身是无限循环的,播放(startAnimating)和停止(stopAnimating)是没有问题;
如果动态图本身就是循环有限次(3次),当循环停止后,再使用播放(startAnimating)没有作用;
怎样才能再次启动动态图的播放?
当然YYImage是非常好用的,假如你知道关于这方面的问题,请指教.谢谢!
Change "typeof" to "__typeof" can fix
阁下的东西是我看过国内干货最多的,太多值得我学习的。
非常期待大神的后续作品。
如果方便的话,可否认识下,希望在以后的开发过程中能得到指教。:)
使用carthage编译生成的framework,拖到工程里,然后#import <YYKit/YYKit.h>
编译报错 could not build module 'YYKit'
error: unknown type name 'FOUNDATION_EXPORT'
FOUNDATION_EXPORT double YYKitVersionNumber;
请问怎么解决呀?
闰年计算方法:
1、年份能被4整除;
2、年份若是100的整数倍的话,需被400整除,否则是平年。
但是实现是
- (instancetype)initWithFrame:(CGRect)frame {
if (frame.size.width == 0 && frame.size.height == 0) { // 你好,我问一下这里的代码是为了适配iOS9frame初始化的吗?
frame.size = kSize;
}
self = [super initWithFrame:frame];
// initFrame code
}
imageByRoundCornerRadius UIImage+YYadd里的这个方法,不能把非等宽登高的图片切成圆的,有没有什么方法可以切成圆的?
阅读起来,前一种直观。写起来,后一种省事。
//- (NSString *)md5String
//{
// unsigned char result[CC_MD5_DIGEST_LENGTH];
// CC_MD5(self.bytes, (CC_LONG)self.length, result);
// NSMutableString *hash = [NSMutableString string];
// for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
// [hash appendFormat:@"%02x", result[i]];
// }
// return hash;
//}
if (!_chatContentLabel) {
_chatContentLabel = [YYLabel new];
_chatContentLabel.frame = CGRectMake(70, 36, kScreenWidth-85, 22);
_chatContentLabel.displaysAsynchronously = YES;
_chatContentLabel.ignoreCommonProperties = YES;
_chatContentLabel.textVerticalAlignment = YYTextVerticalAlignmentCenter;
_chatContentLabel.backgroundColor = [UIColor redColor];
[self.contentView addSubview:_chatContentLabel];
}
_chatContentLabel.hidden = NO;
NSMutableAttributedString *text = [self attributeTextWith:_hisfieds.content];
YYTextContainer *container = [YYTextContainer new];
container.size = CGSizeMake(CGRectGetWidth(_chatContentLabel.frame), 22);
container.maximumNumberOfRows = 1;
YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:text];
_chatContentLabel.textLayout = layout;
我这样写的,emoji表情不显示,哪里写的不对吗??
应为:
一个就好。
看到代码里面有的timer执行invalidate在dealloc里面执行,这种情况是不会进入dealloc里面的吧。得先invalidate才会进入dealloc方法吧
[button setImageWithURL:[NSURL URLWithString:mediaLink] forState:UIControlStateNormal placeholder:[[WeTheme instance] emptyComicSquare] options:YYWebImageOptionProgressive |YYWebImageOptionSetImageWithFadeAnimation completion: nil]; 使用这样的代码加载button的图片,缓存失败的话会被白色图片替代。
YYKit的代码: (YYDiskCache.m)
看下dispatch_async官方文档说明:
block参数系统会自动调用copy,保证self不被释放,在block执行结束后会release。所以没必要传__weak self。 如果传__weak self,就无法保证block在执行时,self是否被释放,反而会出现错误。所以不能传__weak self。
在demo的微博列表里,reload tableView tableView 会发生闪屏的现象。这是为什么?
在使用webP动态图的时候,可不可以把
uint32_t webpLoopCount = WebPDemuxGetI(demuxer, WEBP_FF_LOOP_COUNT);
播放的次数作为一个接口开放出来,可以任意修改,而不是默认读取webP动图本身的循环次数,这样在很大程度上会方便很多.
在swift项目中。按照 『手动安装』 中的步骤把YYKit加入项目中,并且在oc桥接文件中 import "YYKit.h"
,但是在项目中还是不能调用YYKit,请问,在swift项目中还需要做什么步骤吗~
VA_ARGS;
dispatch_semaphore_signal(_lock);
static inline void dispatch_async_on_main_queue(void (^block)()) {
if (pthread_main_np()) {
block(); // 直接执行算同步吧?
} else {
dispatch_async(dispatch_get_main_queue(), block);
}
}
From WBEmoticonGroup:
- (void)modelCustomTransformFromDictionary:(NSDictionary *)dic {
[_emoticons enumerateObjectsUsingBlock:^(WBEmoticon *emoticon, NSUInteger idx, BOOL *stop) {
emoticon.group = self;
}];
}
This returns void
instead of BOOL
. On iOS6 the return value seems to be considered as NO
, which is more reasonable in my perspective, causing crash when entering emoticon panel.
However, on iOS7 and above void
seems to be treated as YES
and the code works. Is this by design or something?
YYLabel使用好繁琐,
YYTextContainer *container = [YYTextContainer containerWithSize:CGSizeMake(self.frameModel.nameF.size.width, self.frameModel.nameF.size.height)];
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:self.frameModel.newsModel.nickname];
YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:text];
self.nameLabel.textLayout = layout;
界面没有显示,请教是怎么回事?
同时引用YYText和YYKit重复YYTextRunDelegate及redefine YYTextVerticalAlignment,望修改以便几个库可以同时引用
我在项目中同时导入了 YYWebImage 、YYCache、YYImage。
一开是我在不知道YYWebImage是包含了其他2个库的
结果我在podfile文件同时引用了这个3个库。冲突了,文件重了!
那可以不可以 用 dependency 的方式去引用 YYCache、YYImage
s.dependency 'YYCache'
s.dependency 'YYImage'
一个注释上的小错误
YYKitMacro.h
中 第237行,对 YYCompileTime
的注视说明中,类型应该为NSDate
,现在是NSData
NSString *macCode=[YYKeychain getPasswordForService:@"123" account:@"YXmacCode" error:nil];
if (macCode==nil) {
macCode=[NSString stringWithUUID];
[YYKeychain setPassword:macCode forService:@"123" account:@"YXmacCode" error:nil];
}
在第一次运行的时候取空值是不报错的,再次运行取值就崩溃了
请问在断点调试时提示编译被优化,那断点调试或者lldb是否不可用?
是否有方法可以获取到设备当前的网速?即上传速度和下载速度?希望添加到UIDevice+YYAdd的#pragma mark - Network Information 中,谢谢!(除了真的用一个测试文件上传/下载,然后体积/用时的这种方法外)
ModelToJSONObjectRecursive中当模型为不合法的字典或者数组时,会对他使用可变的字典或数组进行重新构建,但是在返回结果中没用对其进行copy,这样是否会过分解耦数据,让使用者直接操作修改内部存放的容器?还是为了性能考虑没有进行copy?
你好,请问下 在Feed List Demo中Weibo中 缓存后的圆角头像的大小 比对应url的方形的头像图片的大小要大好几倍,这是UIImageJPEGRepresentation UIImagePNGRepresentation转data后缓存的原因吗?发现SDWebImage中也有这个问题 ,还是我用错呢? 望大牛指导下 3Q
为什么计算lable的像素高度不使用font.lineHeight 属性?是考虑性能的问题吗?还是其他
你好,这个宏有点疑问~
@weakify(nav);
#define weakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
1、前面的@有什么用啊?
2、还有宏中的debug时autoreleasepool{}和后面release时的try catch有什么区别?
同时集成Masonry和YYKit
举例:Masonry 中的类似以下代码make.left.equalTo(_testView2.right) 一句会导致Masonry报 attempting to add unsupported attribute错
[_testView makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(_container);
make.left.equalTo(_testView2.right).offset(5);
make.width.equalTo(120);
make.height.equalTo(32);
}];
- (BOOL)isLeapYear {
NSUInteger year = self.year;
if ((year % 400 == 0) || (year % 100 == 0) || (year % 4 == 0)) return YES;
return NO;
}
西元年份除以400可整除,为闰年。
西元年份除以4可整除但除以100不可整除,为闰年。
我看到Demo里边的布局是用Frame, 现在实际开发中你还会用frame吗, Autolayout呢?
(NSSet<UITouch *> *)这样的用法,导致xcode6无法打开……
发现只集成YYKit还不够,其它的库都是独立的
YYKeyboardManager
YYDispatchQueuePool
YYAsyncLayer
上面三个库用pod search的结果都是unable to find
用的CocoaPods版本是0.39.0,应该是最新的吧,怎么还search不到呢?
我是将YYKit下载下来,将YYKit文件夹加入到项目中,编译后UIDevice+YYAdd.h出现错误
`PhaseScriptExecution Run\ Script /Users/chaoyang/Library/Developer/Xcode/DerivedData/YYKit-Static-dgprtydmnneatjaxszjjpuyeiyso/Build/Intermediates/YYKit-Static.build/Debug-iphoneos/YYKit.build/Script-D9B2622F1BEF581D0038C00A.sh
cd /Users/chaoyang/Desktop/IOS/库文件/YYKit-master/Framework
/bin/sh -c /Users/chaoyang/Library/Developer/Xcode/DerivedData/YYKit-Static-dgprtydmnneatjaxszjjpuyeiyso/Build/Intermediates/YYKit-Static.build/Debug-iphoneos/YYKit.build/Script-D9B2622F1BEF581D0038C00A.sh
UFW (M iphoneos): ERROR: Build failed
Traceback (most recent call last):
File "/Users/chaoyang/Library/Developer/Xcode/DerivedData/YYKit-Static-dgprtydmnneatjaxszjjpuyeiyso/Build/Intermediates/YYKit-Static.build/Debug-iphoneos/YYKit.build/Script-D9B2622F1BEF581D0038C00A.sh", line 812, in
run_build()
File "/Users/chaoyang/Library/Developer/Xcode/DerivedData/YYKit-Static-dgprtydmnneatjaxszjjpuyeiyso/Build/Intermediates/YYKit-Static.build/Debug-iphoneos/YYKit.build/Script-D9B2622F1BEF581D0038C00A.sh", line 745, in run_build
project = Project(os.path.join(os.environ['PROJECT_FILE_PATH'], "project.pbxproj"))
File "/Users/chaoyang/Library/Developer/Xcode/DerivedData/YYKit-Static-dgprtydmnneatjaxszjjpuyeiyso/Build/Intermediates/YYKit-Static.build/Debug-iphoneos/YYKit.build/Script-D9B2622F1BEF581D0038C00A.sh", line 201, in init
self.header_paths = [os.path.join(*x['pathComponents']) for x in self.public_headers]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 73, in join
path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 28: ordinal not in range(128)
Command /bin/sh failed with exit code 1`
不知道啥原因。。。
目前之前SDWebImage 框架的分类方法也是像你目前这样,现在最新版本已经加入了前缀,避免跟系统或其他框架有冲突,有前缀兼容性更好。
例如:
改成:
感觉代码中的圆角设置在非方形图片时有问题,从这里提取了关键代码做了一个简单的测试:
UIImageView *_avatarView = [UIImageView new];
_avatarView.size = CGSizeMake(40, 40);
_avatarView.origin = CGPointMake(160, kWBCellPadding + 3);
_avatarView.contentMode = UIViewContentModeScaleAspectFill;
// _avatarView.clipsToBounds = YES;
[self.view addSubview:_avatarView]; //注意这里是self.view
CALayer *avatarBorder = [CALayer layer];
avatarBorder.frame = _avatarView.bounds;
avatarBorder.borderWidth = CGFloatFromPixel(1);
avatarBorder.borderColor = [UIColor colorWithWhite:0.000 alpha:0.090].CGColor;
avatarBorder.cornerRadius = _avatarView.height / 2;
avatarBorder.shouldRasterize = YES;
avatarBorder.rasterizationScale = kScreenScale;
// [avatarBorder setMasksToBounds:YES];
[_avatarView.layer addSublayer:avatarBorder];
[_avatarView setImageWithURL:[NSURL URLWithString:@"http://pic.qiushibaike.com/system/avtnew/1448/14486583/medium/20140311151742.jpg"] //profileImageURL
placeholder:[UIImage imageNamed:@"defaultLogo"]
options:kNilOptions
manager:[QBStatusHelper avatarImageManager] //< 圆角头像manager,内置圆角处理
progress:nil
transform:nil
completion:nil];
我想这是_avatarView.clipsToBounds未设置为YES的原因,把上面代码中的第一个注释去掉,再运行显示效果如下:
可以看到现在是显示方形了,但是圆角没有了。我想这是圆角在frame之外被clip掉了?把上面代码中的第二个注释去掉也是一样的结果。
我更大的疑问是avatarBorder明明被设置了frame.size为(40,40),为什么addSublayer之后没有遵守这个size呢?求解惑
// YYTextEditExample 这个类的155 行
UIImage *image = [[YYImage alloc] initWithData:data scale:2];
UIImage *resizeImage = [image imageByResizeToSize:CGSizeMake(kScreenWidth, 200)];
UIImageView *imageView = [[YYAnimatedImageView alloc] initWithImage:resizeImage];
可以和MJ的系例比拼一下了,更难得的是po主英文还很厉害。
希望有机会可以为repo做供献。
忘了说了,什么时候出本书啊,讲讲你对ios的认识了解(比如优化性能的思路,算法什么的)。博客看完我还是不过瘾啊。
你写的吗
YYTransaction 头文件描述是
YYTransaction let you perform a selector once before current runloop sleep.
但是YYTransactionSetup()实现是:CFRunLoopRef runloop = CFRunLoopGetMain();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.