iOS images in a bubble effect
You can do this using the GPUImageSphereRefractionFilter from my open source GPUImage framework:
I describe in detail how this works in this answer to a question about a similar affect on Android. Basically, I use a fragment shader to refract the light that passes through an imaginary sphere, then I use that to do a lookup into a texture containing the source image. The background is blurred using a simple Gaussian blur.
If you want to achieve the exact look of the image you show, you might need to tweak this fragment shader to add some grazing-angle color to the sphere, but this should get you fairly close.
For the fun of it, I decided to try to more closely replicate the glass sphere above. I added grazing angle lighting and a specular lighting reflection on the sphere, as well as not inverting the refracted texture coordinates, leading to this result:
I used the following fragment shader for this newer version:
varying highp vec2 textureCoordinate;
uniform sampler2D inputImageTexture;
uniform highp vec2 center;
uniform highp float radius;
uniform highp float aspectRatio;
uniform highp float refractiveIndex;
// uniform vec3 lightPosition;
const highp vec3 lightPosition = vec3(-0.5, 0.5, 1.0);
const highp vec3 ambientLightPosition = vec3(0.0, 0.0, 1.0);
void main()
{
highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
highp float distanceFromCenter = distance(center, textureCoordinateToUse);
lowp float checkForPresenceWithinSphere = step(distanceFromCenter, radius);
distanceFromCenter = distanceFromCenter / radius;
highp float normalizedDepth = radius * sqrt(1.0 - distanceFromCenter * distanceFromCenter);
highp vec3 sphereNormal = normalize(vec3(textureCoordinateToUse - center, normalizedDepth));
highp vec3 refractedVector = 2.0 * refract(vec3(0.0, 0.0, -1.0), sphereNormal, refractiveIndex);
refractedVector.xy = -refractedVector.xy;
highp vec3 finalSphereColor = texture2D(inputImageTexture, (refractedVector.xy + 1.0) * 0.5).rgb;
// Grazing angle lighting
highp float lightingIntensity = 2.5 * (1.0 - pow(clamp(dot(ambientLightPosition, sphereNormal), 0.0, 1.0), 0.25));
finalSphereColor += lightingIntensity;
// Specular lighting
lightingIntensity = clamp(dot(normalize(lightPosition), sphereNormal), 0.0, 1.0);
lightingIntensity = pow(lightingIntensity, 15.0);
finalSphereColor += vec3(0.8, 0.8, 0.8) * lightingIntensity;
gl_FragColor = vec4(finalSphereColor, 1.0) * checkForPresenceWithinSphere;
}
and this filter can be run using a GPUImageGlassSphereFilter.
How to put a marker or bubble on UIImageView?
You should just create a new view (can be UIView or another UIImageView) and add it as a subview of that image view.
speech bubbles like in comics for iphone
I would use a transparent UIView with a UIImageView containing the bubble and a UITextView set editable.
Use this to resize the text view whenever the text view changed notification is sent:
CGRect frame = textview.frame;
frame.size.height = textview.contentSize.height;
Textview.frame = frame;
Subclass the UIView and use touchesbegan and touchesmoved to determine where to move the view as its being dragged.
sizewithfont: constrainedtosize: linebreakmode is the string size method
How to save a UIImage of this layout to the photo album:
CGRect screenRect = CGRectMake(0, 0, 320, 416); // change this as necessary
UIGraphicsBeginImageContext(screenRect.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(screenshot, nil, nil, nil);
Related Topics
Detecting Touches on Mkoverlay in iOS7 (Mkoverlayrenderer)
How to Make Reorder Control of Uitableviewcell in Left Side
Why Is Our Monotouch App Breaking in the Garbage Collector? It Is Not Out of Memory
Https iOS with Self Signed Certificate
1St April Dates of 80S Failed to Parse in iOS 10.0
How to Use Pull to Refresh in Swift
Appdelegate and Scenedelegate When Supporting iOS 12 and 13
Calculate Total Traveled Distance iOS Swift
iOS Avfoundation: Setting Orientation of Video
Google Maps iOS Sdk, Getting Current Location of User
Performseguewithidentifier Very Slow When Segue Is Modal
iOS Calendar Access Permission Dialog, Force It to Appear
Set Image and Title for Bar Button Item
How to Limit an iOS App Only to 4 Inch Screen Devices
How to Both Stroke and Fill with Nsattributedstring W/ Uilabel
How Do We Create a Bigger Center Uitabbar Item
Xmppframework - Retrieve Archived Messages from Openfire Server