2014-09-24 167 views
4

因此,在过去的两周里,我一直在研究我的GitHub回购https://github.com/satheeshwaran/iOS-8-Features-Demo,其中我试图演示iOS 8中引入的Share扩展。我了解了如何添加SLComposeSheetConfigurationItemSLComposeServiceViewController,但我无法弄清楚如何更改SLComposeSheetConfigurationItem的色调颜色或文本颜色。更改SLComposeSheetConfigurationItem的色调颜色/文字颜色

什么我迄今所做的,

enter image description here

见上图中我想设置的描述和我的第一个分享我的一些选择的颜色,也可能是我想自定义字体或其他东西。我挖了一下SocialFramework,但没有得到任何东西。

我看到了我的iPad的Evernote的份额扩展,它看起来像这样, enter image description here

如果您在底部看到有一个图标,也文本颜色等导航栏的主题相匹配。

报价上扩展编程的WWDC 2014演示文稿,

SLComposeServiceViewController标准UI
UI/NSViewController自定义UI 来到我的问题,

  1. 我可以自定义SLComposeServiceViewControllerSLComposeSheetConfigurationItem看起来像这样?
  2. 第二个问题是关于报价,可以默认SLComposeServiceViewController定制?或者我应该用UIViewController子类去做我自己的用户界面。
  3. 怎么会Evernote的做了定制UIViewController子类重复使用SLComposeServiceViewController行为或(我不知道是否要问这个,但我想答案)

回答

6

有关自定义导航栏。 正常的非点符号方法适用于我。

[[[self navigationController] navigationBar] setTintColor:[UIColor whiteColor]]; 
[[[self navigationController] navigationBar] setBackgroundColor:[UIColor redColor]]; 
[[self navigationItem] setTitleView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"elephant.png"]]]; 

对于SLComposeSheetConfigurationItem看起来像给定图标的自定义子类。

进行配置唯一的公共方法上SLComposeSheetConfigurationItem @property (nonatomic, copy) NSString *title; // The displayed name of the option. @property (nonatomic, copy) NSString *value; // The current value/setting of the option. @property (nonatomic, assign) BOOL valuePending; // Default is NO. set to YES to show a progress indicator. Can be used with a value too.

1

其实SLComposeServiceViewController的导航控制器是SLSheetNavigationController,标题视图设置其导航栏似乎没有任何效果,还标题文本属性。

+0

是SLShettNaviagtionController并不像一个正常的UINavigationController了。 – satheeshwaran 2014-10-28 13:41:19

4

我的代码,我用得到类似结果到Evernote:

func getTopWithColor(color: UIColor, size: CGSize) -> UIImage { 
    let rect = CGRectMake(0, 0, size.width, size.height) 
    UIGraphicsBeginImageContextWithOptions(size, false, 0) 
    color.setFill() 
    UIRectFill(rect) 
    if let img = UIImage(named: "icon.png") { 
     img.drawInRect(CGRectMake((size.width-size.height)/2, 0, size.height, size.height)) 
    } 
    let image: UIImage = UIGraphicsGetImageFromCurrentImageContext() 
    UIGraphicsEndImageContext() 
    return image 
} 

override func viewDidLoad() { 
    super.viewDidLoad() 

    self.navigationController?.navigationBar.tintColor = UIColor.blackColor() 
    let navSize = self.navigationController?.navigationBar.frame.size 
    self.navigationController?.navigationBar.setBackgroundImage(getTopWithColor(UIColor.whiteColor(), size: navSize!), forBarMetrics: .Default) 
} 

SLComposeServiceViewController with custom navigation bar

+0

太棒了!任何想法在导航栏上的evernote徽标有点图标设置? – satheeshwaran 2016-03-05 16:25:39

+0

@satheeshwaran在导航栏上添加了丢失的图标,希望对您有所帮助。 – 2016-03-16 19:24:41