user1832451
user1832451

Reputation:

UIActivityViewController Background Color

enter image description hereSo I have a UIActivityViewController in my Application. How do I change the background color. And I also have a quick how to add Facebook and twitter to my UIActivityViewController.

The Code:

    - (IBAction)Social:(id)sender {
            UIActivityViewController *social = [[UIActivityViewController alloc]initWithActivityItems:[NSArray arrayWithObjects:@"Travel+ Rocks",nil] applicationActivities:nil];
            social.excludedActivityTypes = @[UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact,UIActivityTypePostToWeibo,UIActivityTypePrint];   
            [self presentViewController:social animated:YES completion:nil];
            [social setCompletionHandler:^(NSString *activityType, BOOL completed)
             {
                 NSLog(@"Activity = %@",activityType);
                 NSLog(@"Completed Status = %d",completed);

                 if (completed)
                 {
                    // UIAlertView *objalert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Your Posts were sucessful" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                    // [objalert show];
                    // objalert = nil;
                 }else
                 {
                    // UIAlertView *objalert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Your Posts weren't sucessful" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                    // [objalert show];
                    // objalert = nil;



                 }
             }];
        }

These Piece of Code fix the Background Eror:

NSString *message = [NSString stringWithFormat:@""];
    NSString *textToShare = message;
    UIImage *imageToShare = [UIImage imageNamed:@""];
    NSArray *activityItems = [[NSArray alloc]  initWithObjects:textToShare, imageToShare,nil];
    UIActivity *activity = [[UIActivity alloc] init];
    NSArray *applicationActivities = [[NSArray alloc] initWithObjects:activity, nil];
    UIActivityViewController *activityVC =
    [[UIActivityViewController alloc] initWithActivityItems:activityItems
    applicationActivities:applicationActivities];
    [self presentViewController:activityVC animated:YES completion:nil];

Upvotes: 1

Views: 1660

Answers (2)

Skovie
Skovie

Reputation: 197

if you set the targets -> summary -> status Bar style the color of the share view will follow. that the best iv found out .....

enter image description here

hope it helps

Upvotes: 0

Venk
Venk

Reputation: 5955

Have a look on the following linked sample code you may get some idea...

https://github.com/coryalder/DMActivityInstagram/downloads

Upvotes: 1

Related Questions