有没有办法更改UIDocumentInteractionController
navigationbar
的色调/背景颜色?
答案 0 :(得分:14)
@DOOManics实施的更清洁版本:
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
return [self navigationController];
}
答案 1 :(得分:3)
如果将UIDocumentInteractionController放到UINavigationController上,它会自动将颜色设为导航栏。这可能是你的root视图navcontroller。
使用documentInteractionControllerViewControllerForPreview
方法执行此操作:
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller
{
// Use the rootViewController here so that the preview is pushed onto the navbar stack
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
return appDelegate.window.rootViewController;
}
答案 2 :(得分:2)
[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:107.0/256.0 green:145.0/256.0 blue:35.0/256.0 alpha:1.0]];
将此代码放在Appdelegate的didFinisLaunching
方法中。它将改变整个应用程序的导航栏颜色。
答案 3 :(得分:1)
试试这段代码:
- (void)openEC:(NSURL*)url {
[UINavigationBar appearance].tintColor = [UIColor blueColor];
docController = [UIDocumentInteractionController interactionControllerWithURL:url];
[docController setDelegate:self];
[docController presentOptionsMenuFromRect:self.view.bounds inView:self.view animated:YES];
}
- (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *)controller {
[UINavigationBar appearance].tintColor = [UIColor whiteColor];
}
答案 4 :(得分:0)
如果您不使用navigationController,则可以在UIDocumentInteractionController的UIVocumentInteractionController的UIViewController视图上设置正确的设置,从而在UIDocumentInteractionController中设置导航栏颜色。
让我们假设你有UIViewController viewController1(从这里你可以启动UIDocumentInteractionController),在故事板中有一个View1。
打开故事板后,从viewController1上的元素列表中单击View1,然后转到"属性检查器"在右侧。之后将在您的UIDocumentInteractionController中使用Background和Tint设置。
然后你可以使用:
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
return self;
}
请注意,在viewController1中,您可能有一个具有不同属性的导航栏,这些将不会在UIDocumentInteractionController中使用。
答案 5 :(得分:0)
@dvdfrddsgn实现的快速版本
尝试一下:(您需要实现UIDocumentInteractionControllerDelegate)
final topAppBar =
Container(
height: divheight/2*0.1,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
padding: EdgeInsets.all(8.0),
child: Text("tRADING SOLUTION",
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w600
),
),
),
],
),
Column(
//check container widget
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
height: 12,
),
Container(
padding:EdgeInsets.all(5.0),
child: Text("pOWERED BY fLEXI aNALYSIS",
textDirection: TextDirection.rtl,
textAlign: TextAlign.justify,
style: TextStyle(
color: Colors.white,
fontSize: 10,
fontWeight: FontWeight.w600,
fontStyle: FontStyle.italic
),
),
),
],
),
],
),
);
final customAppBar = Container(
height: divheight/2*0.15,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
padding: EdgeInsets.all(10.0),
child: Icon(
Icons.arrow_back,
size: 30.0,
color: Colors.white,),
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
height: 7,
),
Container(
padding:EdgeInsets.all(5.0),
child: Text("Technical Analysis",
textDirection: TextDirection.rtl,
textAlign: TextAlign.justify,
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.w600,
fontStyle: FontStyle.normal
),
),
),
],
),
Container(
padding:EdgeInsets.only(left: 100.0),
child:
IconButton(
icon: Icon(Icons.list),
onPressed: () {},
),
)
],
),
);
final makeBody =
Expanded(
//decoration: BoxDecoration(color: Color.fromRGBO(58, 66, 86, 1.0)),
child:
ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: lessons.length,
itemBuilder: (BuildContext context, int index) {
//get the data from db here through method
return makeCard(lessons[index]);
//makeCard(lessons[index]);
},
),
);
ListView _makeBody() =>ListView(
children: <Widget>[
topAppBar,
customAppBar,
makeBody,
],
);
Scaffold(
backgroundColor: Color.fromRGBO(58, 66, 86, 1.0),
body: _makeBody(),
);