趣好玩开发日志 04-day

    xiaoxiao2025-06-04  20

    趣好玩开发日志 04-day

    占位文字相关

    NSMutableDictionary *dict = [NSMutableDictionary dictionary]; dict[NSForegroundColorAttributeName] = [UIColor whiteColor]; self.attributedPlaceholder = [[NSAttributedString alloc]initWithString:@"11" attributes:dict]; 凡是与设置文字相关的属性,可以找attributed…关键字 第二种方法 //设置占位文字的颜色色 [self setValue:[UIColor whiteColor] forKeyPath:@"placeholderLabel.textColor"];

    监听一个控件的内部事件

    -(void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents{ } 代理通知 //在主线程进行 [NSNotificationCenter defaultCenter]addObserver:<#(nonnull NSObject *)#> forKeyPath:<#(nonnull NSString *)#> options:<#(NSKeyValueObservingOptions)#> context:<#(nullable void *)#> //OC对象发出了名字为name的通知,就在queue队列中执行block self.observer = [NSNotificationCenter defaultCenter]addObserverForName:<#(nullable NSString *)#> object:<#(nullable id)#> queue:<#(nullable NSOperationQueue *)#> usingBlock:^(NSNotification * _Nonnull note) { <#code#> } 利用内部某些机制

    weak与assginde的区别

    weak 对象挂了对象指针自动销毁,一般用于OC(代理)对象assgin 对象挂了对象指针不会自动销毁,容易产生内存泄露(野指针错误)一般用于基本数据类型,如NSString,int

    UITextField 相关

    UIControlEventEditingDidBegin 开始编辑获得焦点弹出键盘UIControlEventEditingDidEnd 结束编辑失去焦点退下键盘
    转载请注明原文地址: https://ju.6miu.com/read-1299602.html
    最新回复(0)