I want to tap on google marker in google map in ios.
I have one google map and marker on map i want to tap on it. Marker is having icon and one lable with number.
Something like above.I am also submitting code of adding marker on map.
let pinView = UIView(frame: CGRect(x: 0, y: 0, width: 40, height: 40))
let circleArrow = UIImageView(frame: CGRect(x: 0, y: 0, width: 40, height: 40))
circleArrow.image = UIImage(named: "circleArrow")
pinView.addSubview(circleArrow)
let ridersLabel = UILabel(frame: CGRect(x: 0, y: 15, width: 40, height: 20))
ridersLabel.text = "\(riders)"
ridersLabel.textAlignment = .center
ridersLabel.textColor = UIColor.white
ridersLabel.transform = CGAffineTransform(rotationAngle: CGFloat(.pi * self.getLabelRotation(heading: heading) / 180.0))
pinView.addSubview(ridersLabel)
pickupMarker.icon = self.imageFromView(aView: pinView)
pickupMarker.rotation = heading
pickupMarker.groundAnchor = CGPoint(x: 0.5, y: 0.5)
pickupMarker.infoWindowAnchor = CGPoint(x: 0.5, y: 1.0)
pickupMarker.map = self.vwMapView
Currently i am trying to get marker like below code UITestCode.
if (self.app.staticTexts["\(n)"].exists)
{
let markerAvailable = self.app.staticTexts["2"]
markerAvailable.tap()
}
Above code in not working.
Solution to at least show pins in accessibility inspector
let mapView = GMSMapView(frame: .zero)
mapView.accessibilityElementsHidden = false
let marker = GMSMarker(position: ...)
marker.accessibilityElementsHidden = false
marker.userData = someString // I used earlgrey to find it by userData, most probably it's possible to find it with default API somehow too
I can search for these pins, but I don't know how to tap them
Related
how can I setting background show full screen?
when I used this code, I can set full screen
private let usernameEmailField: UITextField = {
let field = UITextField()
field.placeholder = "email"
field.returnKeyType = .next
field.leftViewMode = .always
field.leftView = UIView(frame: CGRect(x:0, y:0, width: 10, height: 0))
field.autocapitalizationType = .none
field.autocorrectionType = .no
field.layer.masksToBounds = true
field.layer.cornerRadius = Constants.cornerRadius
field.backgroundColor = .secondarySystemBackground
field.layer.borderWidth = 1.0
field.layer.borderColor = UIColor.secondaryLabel.cgColor
return field
}()
private let headerView: UIView = {
let header = UIView()
header.clipsToBounds = true
let backgroundImageView = UIImageView(image: UIImage(named: "camping_background"))
header.addSubview(backgroundImageView)
return header
}()
headerView.frame = CGRect(
x: 0,
y: 0.0,
width: view.width,
height: view.height
)
usernameEmailField.frame = CGRect(
x: 25,
y: headerView.botoom + 10,
width: view.width - 50,
height: 52.0
)
But if I set height: view.height I can not show my textfield. so how do I modify?
headerView.frame = CGRect(
x: 0,
y: 0.0,
width: view.width,
height: view.height
)
usernameEmailField.frame = CGRect(
x: 25,
y: headerView.botoom + 10,
width: view.width - 50,
height: 52.0
)
passwordField.frame = CGRect(
x: 25,
y: usernameEmailField.botoom + 10,
width: view.width - 50,
height: 52.0
)
if I used height: view.height/3.0, if can show textfield, but the background is not fullscreen
I hope I can show like this one, this is my android page.
so, if I don't use the storyboard, how can I design in the my LoginViewController
Take a look at the code here:
headerView.addSubview(backgroundImageView)
...
headerView.botoom + 10,
You are stacking your views and the background vertically!
But
You should set the image behind the textfields (instead of above them)
Here is the how your view hierarchy could be looks like:
- Main View
- Main Content
- Logo image view
- User name text field
- Password text field
- Login button
- Create account button
- Background image view
As you can see, the Background image view is below the other contents
Note that it's not necessary to group content to layout your view but its very useful method for separating components
ARKit ios related question. the view add into the SCNNode.
my requirement is two label's UIView add into the SCNNode and Show.
//SCNNode Create Function
func Val() -> SCNNode {
//SCNNode Create using SCNode()
let holderNode = SCNNode()
// Set It's Geometry As An SCNPlane
holderNode.geometry = SCNPlane()
// Create A New Material
let material = SCNMaterial()
// Create A UIView As A Holder For Content
let viewToAdd = UIView(frame: CGRect(x: 10, y: 20, width: 300, height: 30))
//background Color
viewToAdd.backgroundColor = .white
// create red Label
let redLabel = UILabel(frame: CGRect(x: 0, y: 10, width: 100, height: 10))
redLabel.text = name
redLabel.textColor = .red
viewToAdd.addSubview(redLabel)
// crate Blue Label
let bluelabel = UILabel(frame: CGRect(x: 0, y: 20, width: 100, height: 20))
bluelabel.text = String(distTwoPoints)
bluelabel.textColor = .red
viewToAdd.addSubview(bluelabel)
material.diffuse.contents = viewToAdd
holderNode.geometry?.firstMaterial = material
holderNode.transform = CardinalDirection.transform(rotationY: GLKMathDegreesToRadians(angle), distance: 500)
// return node
return holderNode
}
Use the following code to add a UIView to a SCNNode:
let plane = SCNPlane()
plane.firstMaterial!.diffuse.contents = viewToAdd
holderNode.geometry = plane
I am looking for some simple method that will animate dots moving by closed path.
I have some path created with UIBezierPath. Which is represented by CAShapeLayer.
I want to place on this shape dots that will move around this closed path. The problem is that I couldn't find the best method. I do not want to add every dot programmatically. Maybe there is some method where could be use particles.
Path will have different shapes. The most important thing is to please dots with the same distance between each other.
I will be glad for help
Here is an example you can run in playground.
It's based on an article by Matt Long (from a while back) http://www.cimgf.com/2009/10/20/marching-ants-with-core-animation/
import UIKit
import PlaygroundSupport
let container = UIView(frame: CGRect(x: 0, y: 0, width: 600, height: 700))
container.backgroundColor = UIColor.green
let v = UIView(frame: CGRect(x: 100, y: 100, width: 300, height: 300))
v.backgroundColor = UIColor.yellow
let shp = CAShapeLayer()
shp.bounds = v.bounds
let pth = UIBezierPath()
pth.move(to: CGPoint(x: 20, y: 220))
pth.addLine(to: CGPoint(x: 20, y: 40))
pth.addLine(to: CGPoint(x: 40, y: 80))
pth.addLine(to: CGPoint(x: 120, y: 40))
pth.addLine(to: CGPoint(x: 140, y: 40))
pth.close()
shp.strokeColor = UIColor.orange.cgColor
shp.fillColor = UIColor.cyan.cgColor
shp.lineWidth = 3.0
shp.lineDashPattern = [5, 5]
shp.path = pth.cgPath
shp.position = CGPoint(x: 150, y: 150)
v.layer.addSublayer(shp)
container.addSubview(v)
let dashAnim = CABasicAnimation(keyPath: "lineDashPhase")
dashAnim.fromValue = 0
dashAnim.toValue = 15
dashAnim.duration = 0.75
dashAnim.repeatCount = 10000
shp.add(dashAnim, forKey: "lineDashPhase")
PlaygroundPage.current.liveView = container
PlaygroundPage.current.needsIndefiniteExecution = true
I am trying to make a view transform and kind of have a circle effect until it reaches certain points then it just fills a rectangle. This is for a material design project I am working on. All the code is in Swift 2.0 on an iOS 8 or above device.
func helloWorld(sender: UIButton) {
let point = sender.frame.origin
let rippleViewInitFrame: CGRect = CGRect(x: point.x, y: point.y, width: 4, height: 4)
let rippleView: UIView = UIView(frame: rippleViewInitFrame)
rippleView.backgroundColor = UIColor.MDColor.blue
let bounds: CGRect = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)
rippleView.layer.masksToBounds = true
rippleView.layer.cornerRadius = 2
self.view.addSubview(rippleView)
UIView.animateWithDuration(0.5, delay: 0.0, options: .CurveEaseInOut, animations: {
rippleView.transform = CGAffineTransformMakeScale(200.0, 200.0)
rippleView.bounds = bounds
}, completion: {
finished in
print(rippleView.frame.origin.x)
})
}
Currently the view just grows beyond the size of the screen.
The print statement returns -37176 instead of say 0. I want it to fill the screen and nothing more.
If you want it to fill a rectangle.
1) create a rectangular container UIView.
2) add your rippleView as a subview to this rectangular uiview.
set the clipsToBounds property to yes of your container view.
and just do the animation.
let rectView = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100));
rectView.backgroundColor = UIColor.redColor()
// initialRippleView
let rippleView = UIView(frame: CGRect(x: 15, y: 15, width: 2, height: 2));
rippleView.backgroundColor = UIColor.whiteColor()
rippleView.cornerRadius = rippleView.width / 2;
rectView.addSubview(rippleView);
rectView.clipsToBounds = true;
UIView.animateWithDuration(5) { () -> Void in
rippleView.transform = CGAffineTransformMakeScale(100, 100);
}
Try in playground.
import UIKit
import XCPlayground
// the main View
let iPhone = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 568));
iPhone.backgroundColor = UIColor.greenColor();
// the rect View that will be the bounds of the animation
let rectView = UIView(frame: CGRect(x: 0, y: 0, width: 150, height: 150));
rectView.backgroundColor = UIColor.redColor()
rectView.center = iPhone.center;
// initialRippleView
let rippleView = UIView(frame: CGRect(x: 15, y: 15, width: 2, height: 2));
rippleView.layer.cornerRadius = 1;
rippleView.backgroundColor = UIColor.whiteColor()
iPhone.addSubview(rectView);
rectView.addSubview(rippleView);
// this property clips the drawings of subview to be clipped to the bounds of rectView.
rectView.clipsToBounds = true;
UIView.animateWithDuration(5) { () -> Void in
// you may need to calculate the right scale factor
rippleView.transform = CGAffineTransformMakeScale(200, 200);
}
// Playground stuff
XCPShowView("Container View", view: iPhone);
Copy this code in a playground File
Show the Assistant editor
Press play (in the left bottom corner)
I want to add rotated elliptical paths to one center point. Like image below but random rotated elliptical.
Draw these elliptical orbits with,
roadShape = SKShapeNode(ellipseInRect: centeredRect)
roadShape.strokeColor = UIColor.greenColor()
self.parent!.addChild(roadShape)
need to make small particles follow those elliptical orbits, thats why I need a path.
var followPath = SKAction.followPath(roadShape.path, asOffset: false, orientToPath: true, duration: 10);
particle.runAction(followPath)
I used SKShapeNode to draw and get the path property. But unfortunately SKShapeNode doesn't have any origin or anchorPoint property so I couldn't decent rotate to SKShapeNode. Do you have any suggestion to make it rotate or different way.
Thanks in advance.
let roadShape1 = SKShapeNode(ellipseInRect: CGRectMake(-100, -25, 200, 50))
roadShape1.strokeColor = UIColor.greenColor()
roadShape1.lineWidth = 3
roadShape1.position = CGPoint(x:frame.midX, y: frame.midY)
addChild(roadShape1)
let roadShape2 = SKShapeNode(ellipseInRect: CGRectMake(-100, -25, 200, 50))
roadShape2.strokeColor = UIColor.greenColor()
roadShape2.lineWidth = 3
let action2 = SKAction.rotateByAngle(CGFloat(M_PI)*0.75, duration:0)
roadShape2.runAction(action2)
roadShape2.position = CGPoint(x:frame.midX, y: frame.midY)
addChild(roadShape2)
let roadShape3 = SKShapeNode(ellipseInRect: CGRectMake(-100, -25, 200, 50))
roadShape3.strokeColor = UIColor.greenColor()
roadShape3.lineWidth = 3
let action3 = SKAction.rotateByAngle(CGFloat(M_PI)*0.25, duration:0)
roadShape3.runAction(action3)
roadShape3.position = CGPoint(x:frame.midX, y: frame.midY)
addChild(roadShape3)
You can also use applyTransform to apply the rotation to the bezierPath
instead of the SKShapeNode as follow:
let roadPath1 = UIBezierPath(ovalInRect: CGRect(x: -100, y: -25, width: 200, height: 50))
let roadPath2 = UIBezierPath(ovalInRect: CGRect(x: -100, y: -25, width: 200, height: 50))
roadPath2.applyTransform(CGAffineTransformMakeRotation(45.0 * CGFloat(M_PI) / 180))
let roadPath3 = UIBezierPath(ovalInRect: CGRect(x: -100, y: -25, width: 200, height: 50))
roadPath3.applyTransform(CGAffineTransformMakeRotation(135.0 * CGFloat(M_PI) / 180))
let roadShape1 = SKShapeNode(ellipseInRect: CGRectMake(-100, -25, 200, 50))
roadShape1.path = roadPath1.CGPath
roadPath1.stroke()
roadShape1.lineWidth = 3
roadShape1.position = CGPoint(x:frame.midX, y: frame.midY)
addChild(roadShape1)
let roadShape2 = SKShapeNode(ellipseInRect: CGRectMake(-100, -25, 200, 50))
roadShape2.path = roadPath2.CGPath
roadPath2.stroke()
roadShape2.lineWidth = 3
roadShape2.position = CGPoint(x:frame.midX, y: frame.midY)
addChild(roadShape2)
let roadShape3 = SKShapeNode(ellipseInRect: CGRectMake(-100, -25, 200, 50))
roadShape3.path = roadPath3.CGPath
roadPath3.stroke()
roadShape3.lineWidth = 3
roadShape3.position = CGPoint(x:frame.midX, y: frame.midY)
addChild(roadShape3)