Tag: 评价

观察UIView更改崩溃

我已经使用下面的代码来确定视图何时被添加到超级视图: //Makes views announce their change of superviews Method method = class_getInstanceMethod([UIView class], @selector(willMoveToSuperview:)); IMP originalImp = method_getImplementation(method); void (^ block)(id, UIView *) = ^(id _self, UIView *superview) { [_self willChangeValueForKey:@"superview"]; originalImp(_self, @selector(willMoveToSuperview:), superview); [_self didChangeValueForKey:@"superview"]; }; IMP newImp = imp_implementationWithBlock((__bridge id)((__bridge void*)block)); method_setImplementation(method, newImp); 我没有任何问题,但是当我尝试运行在64位 ,我得到 originalImp(_self,@selector(willMoveToSuperview :),superview)上的EXC_BAD_ACCESS(code = EXC_I386_GPFLT); 任何人有任何见解? 谢谢

我想在UIView上绘制像苹果形状的自定义形状

我正在努力使苹果有一种进步的形象。 我有select使用.png图像,但我不能因为我必须填充苹果形状不同颜色取决于百分比状态..我使用UIView 绘制这种形状… 我想build议如何轻松画出苹果的那种形状? 而我们怎样才能用不同的颜色填充一半颜色?