iOS 自定義微信分享底部彈出選擇介面

2021-07-10 16:40:32 字數 3556 閱讀 7206

//

//  sharecustom.h

//  hengtaixingolf

////  created by 歐陽榮 on 16/3/22.

//#import

@inte***ce sharecustom : nsobject

+(void)sharewithcontent:(id)publishcontent;//

自定義分享介面

@end

////  sharecustom.m

//  hengtaixingolf

////  created by 歐陽榮 on 16/3/22.

//#import "sharecustom.h"

#import "wxapi.h"

//裝置物理大小

#define kscreenwidth   [uiscreen mainscreen].bounds.size.width

#define kscreenheight  [uiscreen mainscreen].bounds.size.height

#define system_version   [[uidevice currentdevice].systemversion floatvalue]

//螢幕寬度相對iphone6螢幕寬度的比例

#define kwidth_scale    [uiscreen mainscreen].bounds.size.width/640.0f

@implementationsharecustom

static

id_publishcontent;//類方法中的全域性變數這樣用(型別前面加static)

/*自定義的分享類,使用的是類方法,其他地方只要構造分享內容publishcontent就行了

*/+(

void

)sharewithcontent:(

id)publishcontent/*只需要在分享按鈕事件中

構建好分享內容publishcontent傳過來就好了*/

else

button.tag = 331+i;

[button addtarget:

self

action:

@selector

(sharebtnclick:) forcontrolevents:uicontroleventtouchupinside];

[shareview addsubview:button];

}uibutton *canclebtn = [[uibutton

alloc] initwithframe:cgrectmake(0, shareview.frame.size.height-80*kwidth_scale,iphone_width, 80*kwidth_scale)];

//    [canclebtn setbackgroundimage:[uiimage imagenamed:@"ios-取消@2x.png"] forstate:uicontrolstatenormal];

canclebtn.tag = 339;

[canclebtn settitlecolor:[uicolor blackcolor] forstate:uicontrolstatenormal];

canclebtn.backgroundcolor = kcolor(246, 246, 246);

[canclebtn settitle:@"

取消" forstate:uicontrolstatenormal];

[canclebtn addtarget:self action:@selector(sharebtnclick:) forcontrolevents:uicontroleventtouchupinside];

[shareview addsubview:canclebtn];

//為了彈窗不那麼生硬,這裡加了個簡單的動畫

//    shareview.transform = cgaffinetransformmakescale(1/300.0f, 1/270.0f);

//    uiview *blackview = [[uiview alloc] initwithframe:cgrectmake(0, 0, kscreenwidth, kscreenheight)];

shareview.frame = cgrectmake(0,kscreenheight, iphone_width, 300*kwidth_scale);

;blackview.alpha = 0;

[uiview animatewithduration:0.35f animations:^ completion:^(bool finished) ];

}+(void)sharebtnclick:(uibutton *)btn

completion:^(bool finished) ];

int sharetype = 0;

id publishcontent = _publishcontent;

switch (btn.tag)

break;

case

332:

break;

case

339:

break;

default:

break;}/*

呼叫sharesdk的無ui分享型別,

*///    [sharesdk showshareviewwithtype:sharetype container:nil content:publishcontent statusbartips:yes authoptions:nil shareoptions:nil result:^(sharetype type, ssresponsestate state, idstatusinfo, iderror, bool end)

//        else if (state == ssresponsestatefail)

//       

//    }];}//

構造分享內容

//idpublishcontent = [sharesdk content:str1

//                                   defaultcontent:str1

//                                            image:nil

//                                            title:@" "

//                                              url:urlstring

//                                      description:str1

//                                        mediatype:sspublishcontentmediatypetext];

呼叫自定義分享

//[sharecustom sharewithcontent:publishcontent];

//@end

微信自定義分享

1 先獲取 access token 的值,並將 access token 值儲存到資料庫的,也可以利用快取等,看個人習慣 public function getaccesstoken else if res else return data new else return error else r...

微信自定義分享

1 先獲取 access token 的值,並將 access token 值儲存到資料庫的,也可以利用快取等,看個人習慣 public function getaccesstoken else if res else return data new else return error else r...

微信小程式之自定義底部彈出框動畫

最近做小程式時,會經常用到各種彈框。直接做顯示和隱藏雖然也能達到效果,但是體驗性太差,也比較簡單粗暴。想要美美地玩,新增點動畫還是非常有必要的。下面做乙個底部上滑的彈框。wxml view class modals modals bottom dialog hidden view class mod...