jiGuangXieZuo/ProductApp/ProductApp/ProductMain/首页/写作分享/分享海报views/FenXiangHaiBaoView.m

290 lines
9.1 KiB
Objective-C

//
// FenXiangHaiBaoView.m
// ProductApp
//
// Created by 工作 on 2024/9/29.
//
#import "FenXiangHaiBaoView.h"
#import "FenXiangHaiBaoInfoSuperView.h"
#import "FenXiangHaiBaoInfoSuperItemView.h"
#import "FXWDPFView.h"
#import "FXTextView.h"
#import "FXXieZuoJianYiView.h"
#import "FXErView.h"
@interface FenXiangHaiBaoView ()
///
@property (nonatomic , strong) UIView *scvback;
///
@property (nonatomic , strong) UIImage *imageCreate;
@end
@implementation FenXiangHaiBaoView
-(id)initWithFrame:(CGRect)frame
{
if(self = [super initWithFrame:frame])
{
UIScrollView *scvback = [[UIScrollView alloc] init];
[self addSubview:scvback];
[scvback mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.offset(0);
make.width.height.equalTo(self);
}];
_scvback = scvback;
UIView *viewback = [[UIView alloc] init];
[scvback addSubview:viewback];
[viewback mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.width.equalTo(scvback);
}];
_scvback = viewback;
[scvback mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(viewback);
}];
UIImageView *imgvback = [[UIImageView alloc] init];
[imgvback setImage:[UIImage imageNamed:@"hb_back"]];
[viewback addSubview:imgvback];
[imgvback mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.width.equalTo(viewback);
}];
[self drawUI];
}
return self;
}
-(void)drawUI
{
///图片
UIView *viewlast;
for(int i = 0 ; i < 3; i++)
{
UIImageView *imgvback = [[UIImageView alloc] init];
[imgvback setImage:[UIImage imageNamed:[NSString stringWithFormat:@"yd_xs_%d",i]]];
[self.scvback addSubview:imgvback];
[imgvback mas_makeConstraints:^(MASConstraintMaker *make) {
if(viewlast)
{
make.top.equalTo(viewlast.mas_bottom);
}
else
{
make.top.offset(20);
}
make.left.offset(16);
make.width.offset(UISCREEN_WIDTH-32);
}];
viewlast = imgvback;
}
///综合评价
FenXiangHaiBaoInfoSuperView *viewzh = [FenXiangHaiBaoInfoSuperView new];
[self.scvback addSubview:viewzh];
[viewzh mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.width.equalTo(self.scvback);
make.top.equalTo(viewlast.mas_bottom).offset(7);
}];
viewzh.strtitle = @"综合评价";
FenXiangHaiBaoInfoSuperItemView *viewwdpj = [FenXiangHaiBaoInfoSuperItemView new];
[viewzh addSubview:viewwdpj];
[viewwdpj mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(16);
make.right.equalTo(viewzh).offset(-16);
make.top.offset(149);
}];
viewwdpj.strtitle = @"维度评分";
viewwdpj.type = 0;
FXWDPFView *viewwdpjson = [FXWDPFView new];
viewwdpj.viewinfo = viewwdpjson;
FenXiangHaiBaoInfoSuperItemView *viewqwdp = [FenXiangHaiBaoInfoSuperItemView new];
[viewzh addSubview:viewqwdp];
[viewqwdp mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(viewwdpj);
make.top.equalTo(viewwdpj.mas_bottom).offset(30);
}];
viewqwdp.strtitle = @"全文点评";
viewqwdp.type = 1;
FXTextView *viewqwdpson = [FXTextView new];
viewqwdp.viewinfo = viewqwdpson;
[viewzh mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(viewqwdp).offset(35);
}];
///分句点评
FenXiangHaiBaoInfoSuperView *viewfjdp = [FenXiangHaiBaoInfoSuperView new];
[self.scvback addSubview:viewfjdp];
[viewfjdp mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.width.equalTo(self.scvback);
make.top.equalTo(viewzh.mas_bottom).offset(35);
}];
viewfjdp.strtitle = @"分句点评";
UIView *viewitemlast = nil;
for(int i = 0 ; i < 5; i++)
{
FenXiangHaiBaoInfoSuperItemView *viewitem = [FenXiangHaiBaoInfoSuperItemView new];
[viewfjdp addSubview:viewitem];
[viewitem mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(16);
make.right.equalTo(viewfjdp).offset(-16);
if(viewitemlast)
{
make.top.equalTo(viewitemlast.mas_bottom).offset(30);
}
else
{
make.top.offset(149);
}
}];
viewitem.strtitle = @"句子点评①";
viewitem.type = i%2;
FXTextView *viewitemson = [FXTextView new];
viewitem.viewinfo = viewitemson;
viewitemlast = viewitem;
}
[viewfjdp mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(viewitemlast).offset(35);
}];
///写作思路
FenXiangHaiBaoInfoSuperView *viewxzsl = [FenXiangHaiBaoInfoSuperView new];
[self.scvback addSubview:viewxzsl];
[viewxzsl mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.width.equalTo(viewfjdp);
make.top.equalTo(viewfjdp.mas_bottom).offset(35);
}];
viewxzsl.strtitle = @"写作思路";
FenXiangHaiBaoInfoSuperItemView *viewdianpin = [FenXiangHaiBaoInfoSuperItemView new];
[viewxzsl addSubview:viewdianpin];
[viewdianpin mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(16);
make.right.equalTo(viewxzsl).offset(-16);
make.top.offset(149);
}];
viewdianpin.strtitle = @"思路点评";
viewdianpin.type = 0;
FXTextView *viewdianpinson = [FXTextView new];
viewdianpin.viewinfo = viewdianpinson;
FenXiangHaiBaoInfoSuperItemView *viewjianyi = [FenXiangHaiBaoInfoSuperItemView new];
[viewxzsl addSubview:viewjianyi];
[viewjianyi mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(viewdianpin);
make.top.equalTo(viewdianpin.mas_bottom).offset(30);
}];
viewjianyi.strtitle = @"写作建议";
viewjianyi.type = 1;
FXXieZuoJianYiView *viewjianyison = [FXXieZuoJianYiView new];
viewjianyi.viewinfo = viewjianyison;
[viewxzsl mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(viewjianyi);
}];
///二维码
FXErView *viewer = [FXErView new];
[self.scvback addSubview:viewer];
[viewer mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(viewxzsl);
make.top.equalTo(viewxzsl.mas_bottom).offset(40);
}];
UIView *viewshare = [[UIView alloc] init];
[viewshare setBackgroundColor:[UIColor whiteColor]];
[self.scvback addSubview:viewshare];
[viewshare mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(viewer);
make.top.equalTo(viewer.mas_bottom).offset(1);
make.height.offset(108);
}];
[self drawShareView:viewshare];
[self.scvback mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(viewshare);
}];
}
-(void)drawShareView:(UIView *)view
{
float f_w = (UISCREEN_WIDTH-40)/3.0;
NSArray *arr = @[@"微信分享",@"朋友圈",@"保存图片"];
for(int i = 0 ; i < arr.count; i++)
{
UIButton *btitem = [[UIButton alloc] init];
[btitem setTitle:arr[i] forState:UIControlStateNormal];
[btitem setTitleColor:RGBCOLOR(26, 26, 26) forState:UIControlStateNormal];
[btitem.titleLabel setFont:[UIFont systemFontOfSize:15]];
[btitem setImage:[UIImage imageNamed:[NSString stringWithFormat:@"hb_%@",arr[i]]] forState:UIControlStateNormal];
[view addSubview:btitem];
[btitem mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.equalTo(view);
make.left.offset(20+f_w*i);
make.width.offset(f_w);
}];
[btitem setIconInTopWithSpacing:4];
[btitem setTag:i];
[btitem addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
}
}
-(void)shareAction:(UIButton *)sender
{
switch (sender.tag) {
case 0:
{
}
break;
case 1:
{
}
break;
case 2:
{
self.imageCreate = [self jietu];
UIImageWriteToSavedPhotosAlbum(self.imageCreate, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
break;
default:
break;
}
}
-(UIImage *)jietu
{
float fheight = self.scvback.height-108;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(UISCREEN_WIDTH, fheight), NO, 0.0);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.scvback.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
if(!error)
{
[HXHud showMessage:@"保存成功" afterDelayType:0];
}
}
@end