2014-09-24 164 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