# Print image on top of imagePicker when taking photo (swift4)

**URL:** <https://forums.kodeco.com/t/print-image-on-top-of-imagepicker-when-taking-photo-swift4/37550>\
**Category:** Swift\
**Created:** [December 13, 2017, 4:50am UTC](https://forums.kodeco.com/t/print-image-on-top-of-imagepicker-when-taking-photo-swift4/37550 "2017-12-13T04:50:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![timswift](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/timswift/32/110937_2.png) [@timswift](https://forums.kodeco.com/u/timswift)\
**Post date:** [December 13, 2017, 4:50am UTC](https://forums.kodeco.com/t/print-image-on-top-of-imagepicker-when-taking-photo-swift4/37550/1 "2017-12-13T04:50:29Z")

</div>

Right now my code does a two step process to print a image Over the current image. Take Image and save image to imageView. Then via another button its print the image over the imageView. How can I do all of this in 1 button not 2.

```
                              @IBAction func takePhoto(_ sender: UIButton) {
imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .camera
present(imagePicker, animated: true, completion: nil)
imagePicker.cameraOverlayView = mainView

    }
 @IBAction func Mask(_ sender: Any) {
let bottomImage:UIImage = UIImage(named: "backdropd")!

let heart:UIImage = UIImage(named: "edit")!

let newSize = CGSize(width: bottomImage.size.width, height: bottomImage.size.height )
let newSize2 = CGSize(width: bottomImage.size.width, height: bottomImage.size.height)
UIGraphicsBeginImageContextWithOptions(newSize, false, bottomImage.scale)
let left:UIImage = imageTake.image!

left.draw(in: CGRect(x: newSize2.width/5,y: newSize2.height/5,width: newSize2.width/2,height: newSize2.height/5), blendMode:CGBlendMode.normal, alpha:1.0)

heart.draw(in: CGRect(x: 0,y: 0,width: newSize2.width,height: newSize2.height), blendMode:CGBlendMode.normal, alpha:1.0)

let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()

imageTake.image = newImage

     }

```

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [December 13, 2017, 1:01pm UTC](https://forums.kodeco.com/t/print-image-on-top-of-imagepicker-when-taking-photo-swift4/37550/2 "2017-12-13T13:01:52Z")

</div>

Hi there! Why don’t you implement both steps in the same `IBAction` (not quite sure from your code what’s actually stopping you from doing just that after all but I may be wrong and missing something over here though)? Cheers! :]

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [May 28, 2018, 8:50pm UTC](https://forums.kodeco.com/t/print-image-on-top-of-imagepicker-when-taking-photo-swift4/37550/3 "2018-05-28T20:50:30Z")

</div>

This topic was automatically closed after 166 days. New replies are no longer allowed.
