设置NavigationBar半透明时我遇到了一个错误

时间:2016-04-06 06:53:54

标签: ios objective-c iphone

当我将 function ssForward() { // DEFINE YOUR MAIN SPREADSHEET var ss = SpreadsheetApp.openById("SPREADSHEET_ID_ITS_IN_THE_SS_URL"); // DEFINE THE DATA SHEET THAT RECIEVES THE SUBMISSIONS HERE var dataSheet = ss.getSheetByName("data"); // DEFINE THE TEMPLATE SHEET THAT HAS THE EMAIL TEMPLATE INSIDE OF IT var templetSheet = ss.getSheetByName("template"); //DEFINE THE CELLS THAT CONTAIN THE TEMPLATE TEXT FOR THE SUBJECT var templateSubject = templetSheet.getRange(1, 2).getValue(); //DEFINE THE CELLS THAT CONTAIN THE TEMPLATE TEXT FOR THE SUBJECT var templateBody = templetSheet.getRange(2, 2).getValue(); //NOW RUN A FOR LOOP THAT GOES THROUGH EACH ENTRY IN EACH ROW (var i = the row in your spreadsheet ) for (var i = 2; i <= dataSheet.getLastRow(); i++) { // ADD CURRENTLY VIEWED ENTRY TO VAR (var phone = the sheet in row i, column 3) // all 3 of these var work the same way var phone = dataSheet.getRange(i, 3).getValue(); var location = dataSheet.getRange(i, 4).getValue(); var status = dataSheet.getRange(i, 10).getValue(); // NOW USE THE templetSheet VAR DEFINED ABOVE AND REPLACE THE PLACEHOLDER TEXT WITH THE APPROPRIATE VARIABLE //REPLACE THE SUBJECT TEMPLATE TEXT <<phone>> WITH THE CONTENTS OF THE VAR 'phone' defined above. var subject = templateSubject.replace("<<phone>>", phone); //REPLACE THE 'SUBJECT TEMPLATE' TEXT: <<location>> - WITH THE CONTENTS OF THE VAR 'location' defined above. var body = templateBody.replace("<<location>>", location); //REPLACE THE 'SUBJECT TEMPLATE' TEXT: <<phone>> - WITH THE CONTENTS OF THE VAR 'phone' defined above. body = body.replace("<<phone>>", phone); // IF OUR STATUS CELL IS EMPTY if (status == "") { // SEND THE EMAIL FROM 'DESIRED@EMAIL.com', USE THE 'subject' VAR FOR THE SUBECT, AND THE VAR 'templateBody' FOR THE MESSAGES BODY MailApp.sendEmail('YOUR@EMAIL.com', subject, body); // MARK THE ROW AS COMPLETED dataSheet.getRange(i, 10).setValue("Email Notification Sent"); } } } 设置为半透明时,我预计NavigationBar下面不会有阴影线,而NavigationBar具有与视图背景相同的背景the result what I expect

我这样编码:

StatusBar

它们完美适用于5.5英寸iPhone,如iPhone6 Plus和iPhone 6s Plus,但是当在iPhone 6s和iPhone 5s等小型iPhone上运行时,我会遇到类似问题的错误,[self.navigationController.navigationBar setTranslucent:YES]; [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"translucent_image"] forBarMetrics:UIBarMetricsDefault]; self.navigationController.navigationBar.shadowImage = [UIImage new]; 变成黑色!它们与iOS 8.2,iOS 8.3和iOS 9.2上的代码相同,唯一的区别就是屏幕! black StatusBar when run on iPhone6s, iPhone 6 and iPhone 5s

我尝试将StatusBarBarMetrics更改为UIBarMetricsDefaultUIBarMetricsCompact以解决此问题,最后UIBarMetricsDefaultPrompt工作正常,但阴影线来了所有iPhone都出来了!

StatusBar

a shadow line come out

很奇怪!这是iOS的错误吗?

1 个答案:

答案 0 :(得分:0)

尝试将代码更改为

[self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc]init] forBarMetrics:UIBarMetricsDefault];

这对我有用(即我没有得到影子)