iOS更改ShareSDK默認的分享功能界面


ShareSDK的集成這里就不詳細介紹了, 官網的都已經夠詳細了..

官方的默認分享樣式如下:

貼上我的源代碼:

// 創建分享圖片
    NSString *imageURLString = @"http://mob.com/Assets/images/logo.png?v=20150320";
    NSArray* imageArray = @[imageURLString];

    // 分享內容參數
    NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
    [shareParams SSDKSetupShareParamsByText:self.productModel.data.title
                                     images:imageArray
                                        url:[NSURL URLWithString:@"http://www.konvy.com"]
                                      title:@"xxxx"
                                       type:SSDKContentTypeAuto];
    [shareParams SSDKEnableUseClientShare];
    
    __weak typeof(self) weakSelf = self;
    // 分享
    [ShareSDK showShareEditor:type
           otherPlatformTypes:nil
                  shareParams:shareParams
          onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
        switch (state) {
            case SSDKResponseStateSuccess:
                NSLog(@"success");
                break;
            case SSDKResponseStateFail:
                NSLog(@"fail");
                break;
            default:
                break;
        }
    }];

下面是修改樣式的代碼(貌似在官網我沒找到這個東西, 希望下面代碼對大家有點作用):

需要注意的是, 這里需要集成ShareSDKUI模塊(cocoapods可以通過pod 'ShareSDK3/ShareSDKUI'集成..)

然后在需要修改分享視圖樣式的地方導入, 代碼貼上..

#import <ShareSDK/ShareSDK.h>
#import <ShareSDKUI/ShareSDK+SSUI.h>
#import <ShareSDKUI/SSUIEditorViewStyle.h> 

.....

// 創建分享圖片
    NSString *imageURLString = @"http://mob.com/Assets/images/logo.png?v=20150320";
    NSArray* imageArray = @[imageURLString];

    // 分享內容參數
    NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
    [shareParams SSDKSetupShareParamsByText:self.productModel.data.title
                                     images:imageArray
                                        url:[NSURL URLWithString:@"http://www.xxxx.com"]
                                      title:@"xxxx"
                                       type:SSDKContentTypeAuto];
    [shareParams SSDKEnableUseClientShare];
    

    // 初始化編輯界面
    [SSUIEditorViewStyle setiPhoneNavigationBarBackgroundColor:RPNavBarColor];
    [SSUIEditorViewStyle setTitleColor:[UIColor whiteColor]];
    [SSUIEditorViewStyle setCancelButtonLabelColor:[UIColor whiteColor]];
    [SSUIEditorViewStyle setShareButtonLabelColor:[UIColor whiteColor]];
    [SSUIEditorViewStyle setTitle:@"Share"];
    [SSUIEditorViewStyle setCancelButtonLabel:RPLocaolizedStringForKey(@"Cancel_Title")];
    [SSUIEditorViewStyle setShareButtonLabel:RPLocaolizedStringForKey(@"Sure_Title")];
    
    // 分享
    [ShareSDK showShareEditor:type
           otherPlatformTypes:nil
                  shareParams:shareParams
          onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
        switch (state) {
            case SSDKResponseStateSuccess:
                NSLog(@"xxxx");
                break;
            case SSDKResponseStateFail:
                NSLog(@"xxxx");
                break;
            default:
                break;
        }
    }];

另外這里有個比較費解的問題:

如果你使用了下面類似修改控件全局樣式的代碼..可能會導致上面部分代碼失效, 我問了他們的技術人員, 他們一味的說不知道...orz..

[[UITextField appearance] setTintColor:[UIColor redColor]];
[[UITextView appearance] setTintColor:[UIColor redColor]];

 下面是修改后的出現的問題..

你會發現左右兩個item的顏色還是沒有改變..

注釋了上面所說的兩行代碼后, 一切就正常了...

另外SSUIEditorViewStyle這個類里面還有其他一些接口可以修改這個界面的樣式, 例如修改按鈕背景圖片啊, 文本內容的北京顏色啊等等...

有興趣的, 可以去看看...

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface SSUIEditorViewStyle : NSObject

/**
*  設置導航欄背景
*
*  @param image 背景圖片
*/
+ (void)setiPhoneNavigationBarBackgroundImage:(UIImage *)image;

/**
 *  設置iPhone導航欄顏色
 *
 *  @param color 背景顏色
 */
+ (void)setiPhoneNavigationBarBackgroundColor:(UIColor *)color;

/**
 *  設置iPad導航欄顏色
 *
 *  @param color 背景顏色
 */
+ (void)setiPadNavigationBarBackgroundColor:(UIColor *)color;

/**
 *  設置編輯界面背景顏色
 *
 *  @param color 背景顏色
 */
+ (void)setContentViewBackgroundColor:(UIColor *)color;

/**
 *  設置標題
 *
 *  @param title 標題
 */
+ (void)setTitle:(NSString *)title;

/**
 *  設置標題文本顏色
 *
 *  @param color 顏色
 */
+ (void)setTitleColor:(UIColor *)color;

/**
 *  設置取消按鈕標簽
 *
 *  @param label 取消按鈕標簽
 */
+ (void)setCancelButtonLabel:(NSString *)label;

/**
 *  設置取消按鈕標簽文本顏色
 *
 *  @param color 顏色
 */
+ (void)setCancelButtonLabelColor:(UIColor *)color;

/**
 *  設置取消按鈕背景
 *
 *  @param image 圖片
 */
+ (void)setCancelButtonImage:(UIImage *)image;

/**
 *  設置分享按鈕標簽
 *
 *  @param label 取消按鈕標簽
 */
+ (void)setShareButtonLabel:(NSString *)label;

/**
 *  設置分享按鈕標簽文本顏色
 *
 *  @param color 顏色
 */
+ (void)setShareButtonLabelColor:(UIColor *)color;

/**
 *  設置分享按鈕背景
 *
 *  @param image 圖片
 */
+ (void)setShareButtonImage:(UIImage *)image;

/**
 *  設置支持的頁面方向(單獨分享編輯頁面)
 */
+ (void)setSupportedInterfaceOrientation:(UIInterfaceOrientationMask)toInterfaceOrientation;

/**
 *  設置分享編輯頁面狀態欄風格
 */
+ (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle;

@end

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM