Commit 3d32af91 cgx

头像图片黑夜模式适配

1 个父辈 9bbde2ef
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
- (UIImageView *)portraitIV { - (UIImageView *)portraitIV {
if (!_portraitIV) { if (!_portraitIV) {
_portraitIV = [UIImageView new]; _portraitIV = [UIImageView new];
_portraitIV.dk_alphaPicker = DKAlphaPickerWithAlphas(1, .5, .5);
[_portraitIV yy_setImageWithURL:[NSURL URLWithString:[LoginUtils getFaceImg]] placeholder:[UIImage imageNamed:@"portrait"]]; [_portraitIV yy_setImageWithURL:[NSURL URLWithString:[LoginUtils getFaceImg]] placeholder:[UIImage imageNamed:@"portrait"]];
[_portraitIV cornerRadius:145/2.0]; [_portraitIV cornerRadius:145/2.0];
} }
...@@ -103,6 +104,7 @@ ...@@ -103,6 +104,7 @@
- (UIImageView *)cameraIV { - (UIImageView *)cameraIV {
if (!_cameraIV) { if (!_cameraIV) {
_cameraIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cameraIcon"]]; _cameraIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cameraIcon"]];
_cameraIV.dk_alphaPicker = DKAlphaPickerWithAlphas(1, .5, .5);
} }
return _cameraIV; return _cameraIV;
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#import "UserRequestModel.h" #import "UserRequestModel.h"
@interface UserInfoView () <InfoModifyAlertViewDelegate, DSImagePickerControllerDelegate, RSKImageCropViewControllerDelegate> @interface UserInfoView () <InfoModifyAlertViewDelegate, DSImagePickerControllerDelegate, RSKImageCropViewControllerDelegate>
@property (nonatomic, strong) UIButton *portraitBtn; @property (nonatomic, strong) UIImageView *portraitIV;
@property (nonatomic, strong) InfoModifyAlertView *photoAlertView; @property (nonatomic, strong) InfoModifyAlertView *photoAlertView;
@property (nonatomic, strong) UserInfoTableView *userInfoTV; @property (nonatomic, strong) UserInfoTableView *userInfoTV;
@property (nonatomic, strong) UIButton *layoutBtn; @property (nonatomic, strong) UIButton *layoutBtn;
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
if (self = [super initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kTopHeight(0))]) { if (self = [super initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kTopHeight(0))]) {
_delegate = delegate; _delegate = delegate;
[self.portraitBtn yy_setImageWithURL:[NSURL URLWithString:[LoginUtils getFaceImg]] forState:UIControlStateNormal placeholder:[UIImage imageNamed:@"portrait"]]; [self.portraitIV yy_setImageWithURL:[NSURL URLWithString:[LoginUtils getFaceImg]] placeholder:[UIImage imageNamed:@"portrait"]];
[self addSubview:self.userInfoTV]; [self addSubview:self.userInfoTV];
[self addSubview:self.layoutBtn]; [self addSubview:self.layoutBtn];
...@@ -77,33 +77,34 @@ ...@@ -77,33 +77,34 @@
// 用户头像上传成功后存入沙盒(暂不处理) // 用户头像上传成功后存入沙盒(暂不处理)
if (requestModel.resCode == DSResCodeSuccess) { if (requestModel.resCode == DSResCodeSuccess) {
[DSProgressHUD showToast:@"修改成功"]; [DSProgressHUD showToast:@"修改成功"];
[self.portraitBtn setImage:croppedImage forState:UIControlStateNormal]; self.portraitIV.image = croppedImage;
[self.ds_viewController dismissViewControllerAnimated:YES completion:nil]; [self.ds_viewController dismissViewControllerAnimated:YES completion:nil];
} }
}]; }];
} }
#pragma mark - lazy #pragma mark - lazy
- (UIButton *)portraitBtn { - (UIImageView *)portraitIV {
if (!_portraitBtn) { if (!_portraitIV) {
CGFloat top = iPhone5 ? 40 : 83; CGFloat top = iPhone5 ? 40 : 83;
_portraitBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, top, 145, 145)]; _portraitIV = [[UIImageView alloc] initWithFrame:CGRectMake(0, top, 145, 145)];
_portraitBtn.centerX = self.centerX; _portraitIV.centerX = self.centerX;
[_portraitBtn addTarget:self action:@selector(updatePortraitAction) forControlEvents:UIControlEventTouchUpInside]; _portraitIV.userInteractionEnabled = YES;
_portraitBtn.imageView.contentMode = UIViewContentModeScaleAspectFit; _portraitIV.dk_alphaPicker = DKAlphaPickerWithAlphas(1, .5, .5);
_portraitBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill; UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(updatePortraitAction)];
_portraitBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentFill; [_portraitIV addGestureRecognizer:tapGR];
[_portraitBtn cornerRadius:145/2.0]; [_portraitIV cornerRadius:145/2.0];
[self addSubview:_portraitBtn]; [self addSubview:_portraitIV];
UIImageView *cameraIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cameraIcon"]]; UIImageView *cameraIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cameraIcon"]];
cameraIV.dk_alphaPicker = DKAlphaPickerWithAlphas(1, .5, .5);
[self addSubview:cameraIV]; [self addSubview:cameraIV];
[cameraIV mas_makeConstraints:^(MASConstraintMaker *make) { [cameraIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(_portraitBtn).offset(-6); make.right.equalTo(_portraitIV).offset(-6);
make.bottom.equalTo(_portraitBtn).offset(-6); make.bottom.equalTo(_portraitIV).offset(-6);
}]; }];
} }
return _portraitBtn; return _portraitIV;
} }
- (InfoModifyAlertView *)photoAlertView { - (InfoModifyAlertView *)photoAlertView {
...@@ -115,7 +116,7 @@ ...@@ -115,7 +116,7 @@
- (UserInfoTableView *)userInfoTV { - (UserInfoTableView *)userInfoTV {
if (!_userInfoTV) { if (!_userInfoTV) {
_userInfoTV = [[UserInfoTableView alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.portraitBtn.frame) + 60, kScreenWidth - 30, 150) style:UITableViewStylePlain]; _userInfoTV = [[UserInfoTableView alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.portraitIV.frame) + 60, kScreenWidth - 30, 150) style:UITableViewStylePlain];
} }
return _userInfoTV; return _userInfoTV;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!