OC代碼:
-(void)showAlertView{
CLNNNativeAlertView *alertView=[[CLNNNativeAlertView alloc] initWithTitle:@"請(qǐng)接受相關(guān)協(xié)議" message:@"我同意《租賃協(xié)議》、《芝麻信用免押金額度協(xié)議》、《內(nèi)啥服務(wù)條款》及東家指定的退訂規(guī)則" cancelButtonTitle:@"取消" confirmTitle:@"我同意"];
NSDictionary *linkDic1 = @{NSForegroundColorAttributeName:MAIN_COLOR,NSFontAttributeName:[UIFont systemFontOfSize:15]};
NSDictionary *linkDic2 = @{NSForegroundColorAttributeName:YELLOW_COLOR,NSFontAttributeName:[UIFont systemFontOfSize:15]};
NSLog(@"%@%@",linkDic1,linkDic2);
__weak typeof(self) weakSelf=self;
CJLabelConfigure *configure = [CJLabel configureAttributes:linkDic1 isLink:YES activeLinkAttributes:linkDic2 parameter:WEB_rent clickLinkBlock:^(CJLabelLinkModel *linkModel) {
BrowserViewController *vc=[[BrowserViewController alloc] init];
vc.loadMethod=linkModel.parameter;[weakSelf.navigationController pushViewController:vc animated:YES];
} longPressBlock:nil];
[configure setActiveLinkAttributes:linkDic1];
alertView.messageLabel.text = [CJLabel configureAttrString:alertView.messageLabel.attributedText withString:@"《租賃協(xié)議》" sameStringEnable:YES configure:configure];
CJLabelConfigure *configure1 = [CJLabel configureAttributes:linkDic1 isLink:YES activeLinkAttributes:linkDic2 parameter:WEB_zhima clickLinkBlock:^(CJLabelLinkModel *linkModel) {
BrowserViewController *vc=[[BrowserViewController alloc] init];
vc.loadMethod=linkModel.parameter;
[weakSelf.navigationController pushViewController:vc animated:YES];
} longPressBlock:nil];
alertView.messageLabel.text = [CJLabel configureAttrString:alertView.messageLabel.attributedText withString:@"《芝麻信用免押金額度協(xié)議》" sameStringEnable:YES configure:configure1];
CJLabelConfigure *configure2 = [CJLabel configureAttributes:linkDic1 isLink:YES activeLinkAttributes:linkDic2 parameter:WEB_terms clickLinkBlock:^(CJLabelLinkModel *linkModel) {
BrowserViewController *vc=[[BrowserViewController alloc] init];
vc.loadMethod=linkModel.parameter;
[weakSelf.navigationController pushViewController:vc animated:YES];
} longPressBlock:nil];
alertView.messageLabel.text = [CJLabel configureAttrString:alertView.messageLabel.attributedText withString:@"《內(nèi)啥服務(wù)條款》" sameStringEnable:YES configure:configure2];
alertView.confirmButtonAction=^(){
[weakSelf continuePay];
};
alertView.cancelButtonAction=^(){
};
[alertView showAlert];
}
JS代碼:
require('CLNNNativeAlertView, UIColor, UIFont, BrowserViewController, CJLabel');
defineClass('NewPayController', {
showAlertView: function() {
var alertView=CLNNNativeAlertView.alloc().initWithTitle_message_cancelButtonTitle_confirmTitle("請(qǐng)接受相關(guān)協(xié)議", "我同意《租賃協(xié)議》、《芝麻信用免押金額度協(xié)議》、《內(nèi)啥服務(wù)條款》及東家指定的退訂規(guī)則", "取消", "我同意") ;
var linkDic1 = {
"NSColor":UIColor.colorWithHexString("0097F9"),
"NSFont":UIFont.systemFontOfSize(15)
};
var linkDic2 = {
"NSColor":UIColor.colorWithHexString("ffbb07"),
"NSFont":UIFont.systemFontOfSize(15)
};
var weakSelf = self;
var configure = CJLabel.configureAttributes_isLink_activeLinkAttributes_parameter_clickLinkBlock_longPressBlock(linkDic1, 1, linkDic2, "API", block("void, CJLabelLinkModel*", function(linkModel) { var vc=BrowserViewController.alloc().init() ;
vc.setLoadMethod(linkModel.parameter());
weakSelf.navigationController().pushViewController_animated(vc, 1) ;
}), null) ;
alertView.messageLabel().setText(CJLabel.configureAttrString_withString_sameStringEnable_configure(alertView.messageLabel().attributedText(), "《租賃協(xié)議》", 1, configure));
var configure1 = CJLabel.configureAttributes_isLink_activeLinkAttributes_parameter_clickLinkBlock_longPressBlock(linkDic1, 1, linkDic2, "API", block("void, CJLabelLinkModel*", function(linkModel) { var vc=BrowserViewController.alloc().init() ;
vc.setLoadMethod(linkModel.parameter());
weakSelf.navigationController().pushViewController_animated(vc, 1) ;
}), null) ;
alertView.messageLabel().setText(CJLabel.configureAttrString_withString_sameStringEnable_configure(alertView.messageLabel().attributedText(), "《芝麻信用免押金額度協(xié)議》", 1, configure1) );
var configure2 = CJLabel.configureAttributes_isLink_activeLinkAttributes_parameter_clickLinkBlock_longPressBlock(linkDic1, 1, linkDic2, "API", block("void, CJLabelLinkModel*", function(linkModel) {
var vc=BrowserViewController.alloc().init() ;
vc.setLoadMethod(linkModel.parameter());
weakSelf.navigationController().pushViewController_animated(vc, 1) ;
}), null) ;
alertView.messageLabel().setText(CJLabel.configureAttrString_withString_sameStringEnable_configure(alertView.messageLabel().attributedText(), "《內(nèi)啥服務(wù)條款》", 1, configure2) );
alertView.setConfirmButtonAction(block("void, ", function() {
weakSelf.continuePay() ;
}));
alertView.setCancelButtonAction(block("void, ", function() {
}));
alertView.showAlert() ;
}}, {});
總結(jié):NSForegroundColorAttributeName 在js中要寫成"NSColor"。
獲取方法為用NSLog打印,如NSFontAttribute打印出來是NSFont,則在js中寫成"NSFont",注意要加雙引號(hào)。