2017.11
1.父视图透明,子视图正常
blackView.backgroundColor = [UIColor colorWithWhite:0.f alpha:0.6];
更多详细方式参考:iOS 设置视图半透明而子控件不透明
2.UITextField因过滤空格无法回退删除问题
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
NSString *textPsw = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
if (range.length == 1 && textPsw.length == 0) {
return YES;
}
if ([textPsw length] == 0) {
return NO;
}
return YES;
}
3.更改tabbar字体颜色
a.只能改变点击后的颜色
tabbar.tintColor = TABBAR_TITLE_SELECTED_COLOR;
b.能全局改变点击前、后的颜色
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:TABBAR_TITLE_DEFAULT_COLOR} forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:TABBAR_TITLE_SELECTED_COLOR} forState:UIControlStateSelected];
}
c.改变某VC的tabBarItem点击前、后的颜色
[vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:TABBAR_TITLE_DEFAULT_COLOR} forState:UIControlStateNormal];
[vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:TABBAR_TITLE_SELECTED_COLOR} forState:UIControlStateSelected];
4.从导航栏下方开始布局
a.
self.edgesForExtendedLayout = UIRectEdgeNone;
b.将导航栏设置不透明
self.navigationController.navigationBar.translucent = NO;
参考及详细介绍:iOS frame从导航栏下面开始 iOS edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets属性详解
2018.4.19
5.设置按钮点击前后的背景图片
[microphoneBtn setBackgroundImage:[UIImage imageNamed:@"mic_open"] forState:UIControlStateNormal];
[microphoneBtn setBackgroundImage:[UIImage imageNamed:@"mic_close"] forState:UIControlStateSelected];
先设置,点击前后的图片;然后实现点击方法,在其中加上:
sender.selected = !sender.selected;
即可。
6.设置按钮图片之后,点击左上角有蓝色块。
解决:将按钮UIButtonTypeSystem修改成UIButtonTypeCustom。