2018年10月18日 星期四

提早拿到constraint後的frame

加入viewDidLoad可以拿到autolayout後的正確frame

加在animation中,可以在autolayout的情況下作用
[UIView animateWithDuration:0.5 animations:^{
            self.filterViewWidthConstraint.constant = 200;
            [self.view layoutIfNeeded];
        }];

用pdf取代png

在asset中放入pdf,設成all scale,可以用來取代svg當作向量圖。

如果是icon的話,還可以設成templete,可以用tintColor來改變icon的顏色。

超級實用的小技巧

2018年10月15日 星期一

Add touch began to pan gesture

!!!!!!一定要做#import "UIPanGestureRecognizerSubclass.h"
然後用category或是subclass去設定這個state,
才能用readwrite不然,原本的recognizer是readonly










@interface TouchableImageView:UIImageView
@property(strong, nonatomic) UIPanGestureRecognizer *panGR; // 這裡要改成自己的recognizer或是實作一個category
@end

@implementation TouchableImageView
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    self.panGR.state = UIGestureRecognizerStateBegan;
}
@end
//直接改狀態就能trigger gesture的began!!